/*
 * Englishbuds Games
 * Shared Theme
 */

:root {
  /* Englishbuds brand colors */
  --eb-green: #7fb51c;
  --eb-green-dark: #4f7f18;
  --eb-green-light: #dff1a8;

  /* Game accent colors */
  --eb-yellow: #ffd83d;
  --eb-pink: #ffb8c8;
  --eb-blue: #8ed8f8;
  --eb-orange: #ffb347;

  /* Neutral colors */
  --eb-white: #ffffff;
  --eb-background: #f7faef;
  --eb-text: #333333;
  --eb-text-soft: #666666;
  --eb-border: #dfe7d2;

  /* Feedback colors */
  --eb-success: #63b84f;
  --eb-error: #e86464;

  /* Shape */
  --eb-radius-small: 10px;
  --eb-radius-medium: 18px;
  --eb-radius-large: 28px;

  /* Shadow */
  --eb-shadow:
    0 6px 18px rgba(0, 0, 0, 0.10);

  /* Spacing */
  --eb-space-xs: 4px;
  --eb-space-sm: 8px;
  --eb-space-md: 16px;
  --eb-space-lg: 24px;
  --eb-space-xl: 32px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  background: var(--eb-background);
  color: var(--eb-text);

  font-family:
    "Arial Rounded MT Bold",
    "Trebuchet MS",
    Arial,
    sans-serif;

  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  touch-action: manipulation;
}

img {
  max-width: 100%;
  height: auto;
}

[hidden] {
  display: none !important;
}

/*
 * Englishbuds Games
 * Shared Components
 */

/* Main game container */
.eb-game {
  width: min(100% - 24px, 960px);
  margin: 0 auto;
  padding: var(--eb-space-md);
}

/* Card */
.eb-card {
  background: var(--eb-white);
  border: 1px solid var(--eb-border);
  border-radius: var(--eb-radius-large);
  box-shadow: var(--eb-shadow);
  padding: var(--eb-space-lg);
}

/* Primary button */
.eb-button {
  min-height: 52px;
  padding: 12px 24px;

  border: none;
  border-radius: var(--eb-radius-medium);

  background: var(--eb-green);
  color: var(--eb-white);

  font-weight: 700;
  font-size: 1rem;

  cursor: pointer;

  transition:
    transform 0.15s ease,
    opacity 0.15s ease;
}

.eb-button:hover {
  transform: translateY(-2px);
}

.eb-button:active {
  transform: translateY(0);
}

.eb-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Secondary button */
.eb-button-secondary {
  background: var(--eb-white);
  color: var(--eb-green-dark);
  border: 2px solid var(--eb-green);
}

/* Icon button */
.eb-icon-button {
  width: 48px;
  height: 48px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border: none;
  border-radius: 50%;

  background: var(--eb-white);
  box-shadow: var(--eb-shadow);

  cursor: pointer;
}

/* Header */
.eb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: var(--eb-space-md);
  margin-bottom: var(--eb-space-lg);
}

/* Englishbuds logo */
.eb-logo {
  display: block;
  width: min(220px, 55vw);
  height: auto;
}

/* Mascot */
.eb-mascot {
  display: block;
  width: min(220px, 55vw);
  height: auto;
}

/* Score / information display */
.eb-status {
  display: flex;
  align-items: center;
  justify-content: center;

  gap: var(--eb-space-md);

  font-weight: 700;
  font-size: 1.1rem;
}

/* Result message */
.eb-message {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
}

/* Success */
.eb-message-success {
  color: var(--eb-success);
}

/* Error */
.eb-message-error {
  color: var(--eb-error);
}

/* Mobile */
@media (max-width: 600px) {
  .eb-game {
    width: 100%;
    padding: 12px;
  }

  .eb-card {
    padding: var(--eb-space-md);
  }

  .eb-button {
    min-height: 56px;
    width: 100%;
  }
}

/* Englishbuds Othello Game */

:root {
  --board-green: #3f8d57;
  --board-green-light: #56a66b;
  --board-line: rgba(20, 70, 37, 0.72);
  --panel-blue-border: #cfe4f1;
  --tool-blue: #327ab8;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 5%, rgba(142, 216, 248, 0.2), transparent 28rem),
    var(--eb-background);
}

button:focus-visible,
.cell:focus-visible {
  outline: 4px solid var(--eb-yellow);
  outline-offset: 3px;
}

.othello-app {
  width: min(100%, 1180px);
  padding-block: 18px 28px;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--eb-space-md);
  margin-bottom: 14px;
  padding: 10px 16px;
  border: 1px solid var(--panel-blue-border);
  border-radius: var(--eb-radius-medium);
  background: rgba(255, 255, 255, 0.94);
}

.brand-title {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 16px;
}

.game-logo {
  width: min(185px, 31vw);
}

.title-divider {
  width: 1px;
  height: 34px;
  background: var(--eb-border);
}

.brand-title h1 {
  margin: 0;
  color: var(--eb-green-dark);
  font-size: clamp(1.25rem, 2.6vw, 2rem);
  line-height: 1.1;
  white-space: nowrap;
}

.restart-button {
  min-height: 44px;
  padding: 9px 18px;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 290px);
  gap: 18px;
  align-items: start;
}

.board-section,
.teacher-panel {
  border: 1px solid var(--eb-border);
  border-radius: var(--eb-radius-large);
  background: var(--eb-white);
  box-shadow: var(--eb-shadow);
}

.board-section {
  display: grid;
  justify-items: center;
  padding: clamp(14px, 2.5vw, 26px);
}

.location-guide {
  position: relative;
  width: min(100%, 720px);
  padding: 0;
}

.guide-label {
  position: absolute;
  display: none;
  color: var(--tool-blue);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.location-guide.active .guide-label {
  display: block;
}

.guide-top,
.guide-bottom {
  left: 50%;
  transform: translateX(-50%);
}

.guide-top { top: -22px; }
.guide-bottom { bottom: -22px; }

.guide-left,
.guide-right {
  top: 50%;
  writing-mode: vertical-rl;
  transform: translateY(-50%);
}

.guide-left {
  left: -28px;
  transform: translateY(-50%) rotate(180deg);
}

.guide-right { right: -28px; }

.board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  width: 100%;
  aspect-ratio: 1 / 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: clamp(5px, 1vw, 10px) solid #2c6940;
  border-radius: 10px;
  background: var(--board-green);
  box-shadow: 0 10px 24px rgba(33, 78, 45, 0.2);
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--board-line);
  border-bottom: 1px solid var(--board-line);
  border-radius: 0;
  background: var(--board-green-light);
  cursor: pointer;
}

.cell:nth-child(8n) { border-right: 0; }
.cell:nth-child(n + 57) { border-bottom: 0; }
.cell:hover { background: #62b678; }

.cell.invalid {
  animation: invalid-cell 0.22s ease;
}

.piece {
  position: absolute;
  width: 78%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  box-shadow:
    inset -3px -4px 6px rgba(0, 0, 0, 0.18),
    0 2px 3px rgba(0, 0, 0, 0.28);
}

.piece.black {
  background: radial-gradient(circle at 32% 27%, #555, #171717 55%, #050505);
}

.piece.white {
  border: 1px solid #d2d2d2;
  background: radial-gradient(circle at 32% 27%, #fff, #f3f3f3 62%, #d8d8d8);
}

.piece.flipping {
  animation: piece-flip 0.4s ease;
}

.cell.last-move::after {
  content: "";
  position: absolute;
  inset: 10.5%;
  border: 2px solid rgba(255, 216, 61, 0.88);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(58, 80, 32, 0.24);
  pointer-events: none;
}

.cell.legal-move::before {
  content: "";
  position: absolute;
  width: 18%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 0 0 2px rgba(25, 87, 44, 0.3);
}

.game-message {
  min-height: 1.5em;
  margin: 12px 0 0;
  color: var(--eb-green-dark);
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
}

.teacher-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.status-card,
.tools-card {
  border-radius: var(--eb-radius-medium);
}

.status-card {
  padding: 14px;
  border: 1px solid var(--eb-border);
}

.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 4px;
  font-size: 1.08rem;
}

.score-row strong {
  font-size: 1.35rem;
}

.score-label {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.mini-piece,
.turn-piece {
  display: inline-block;
  flex: 0 0 auto;
  border-radius: 50%;
}

.mini-piece {
  width: 24px;
  height: 24px;
}

.turn-piece {
  width: 22px;
  height: 22px;
}

.mini-piece.black,
.turn-piece.black { background: #171717; }
.mini-piece.white,
.turn-piece.white {
  border: 1px solid #bfc5c0;
  background: white;
}

.turn-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  background: var(--eb-green-light);
  color: #355517;
  font-weight: 800;
}

.tools-card h2 {
  margin: 0 0 10px;
  color: var(--tool-blue);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.toggle-button {
  min-height: 44px;
  border: 2px solid var(--tool-blue);
  border-radius: 13px;
  background: white;
  color: #245e91;
  font-weight: 700;
  cursor: pointer;
}

.tools-card {
  display: grid;
  gap: 9px;
}

.mascot-area {
  display: grid;
  place-items: end center;
  min-height: 0;
  padding-top: 2px;
}

.teacher-mascot {
  display: block;
  width: min(150px, 76%);
  height: auto;
}

.toggle-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 12px;
}

.toggle-button[aria-pressed="true"] {
  background: var(--tool-blue);
  color: white;
}

.toggle-state {
  padding: 2px 7px;
  border-radius: 999px;
  background: #e9eef2;
  color: #5a6670;
  font-size: 0.72rem;
}

.toggle-button[aria-pressed="true"] .toggle-state {
  background: white;
  color: var(--tool-blue);
}

.result-dialog {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(32, 48, 36, 0.54);
}

.restart-dialog {
  position: fixed;
  z-index: 11;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(45, 61, 48, 0.26);
}

.restart-dialog-card {
  width: min(100%, 360px);
  padding: 24px;
  border: 1px solid var(--eb-border);
  border-radius: var(--eb-radius-medium);
  background: white;
  box-shadow: var(--eb-shadow);
  text-align: center;
}

.restart-dialog-card h2 {
  margin: 0 0 20px;
  color: var(--eb-text);
  font-size: 1.35rem;
}

.restart-dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.restart-dialog-actions .eb-button {
  min-height: 48px;
  padding: 10px 16px;
}

.result-card {
  width: min(100%, 410px);
  padding: 30px;
  border: 5px solid var(--eb-green-light);
  border-radius: var(--eb-radius-large);
  background: white;
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.25);
  text-align: center;
}

.result-eyebrow {
  margin: 0;
  color: var(--tool-blue);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.result-card h2 {
  margin: 8px 0;
  color: var(--eb-green-dark);
  font-size: clamp(1.8rem, 6vw, 2.5rem);
}

.result-card #result-score {
  margin: 0 0 22px;
  font-size: 1.15rem;
}

@keyframes piece-flip {
  0% { transform: scaleX(1); }
  48% { transform: scaleX(0.08); }
  100% { transform: scaleX(1); }
}

@keyframes invalid-cell {
  0%, 100% { background: var(--board-green-light); }
  50% { background: #82bf8d; }
}

@media (max-width: 780px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .teacher-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: center;
  }

  .teacher-mascot {
    width: min(120px, 80%);
  }
}

@media (max-width: 560px) {
  .othello-app {
    width: 100%;
    padding: 10px;
  }

  .game-header {
    align-items: flex-start;
    padding: 10px;
  }

  .brand-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .game-logo {
    width: 142px;
  }

  .title-divider { display: none; }

  .restart-button {
    width: auto;
    min-height: 42px;
    padding-inline: 12px;
  }

  .board-section {
    padding: 10px;
    border-radius: var(--eb-radius-medium);
  }

  .guide-top { top: 4px; }
  .guide-bottom { bottom: 4px; }
  .guide-left { left: 4px; }
  .guide-right { right: 4px; }

  .cell.last-move::after { border-width: 1.5px; }

  .teacher-panel {
    grid-template-columns: 1fr;
  }

  .status-card {
    grid-row: auto;
  }

  .status-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
  }

  .turn-display {
    grid-column: 1 / -1;
  }

  .teacher-mascot {
    width: 105px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
