* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
}

.game-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
}

header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

h1 {
  font-size: clamp(1.5rem, 5vw, 2.3rem);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.back-button {
  padding: 0.55rem 1rem;
  border-radius: 50px;
  text-decoration: none;
  transition: transform 0.2s ease;
}

.mute-btn {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
}

.match-goal,
.side-note,
.mode-hint,
.status {
  text-align: center;
}

.match-goal {
  margin-bottom: 0.85rem;
}

.modes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.65rem;
  margin-bottom: 0.6rem;
}

.mode-btn {
  min-height: 3.25rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: clamp(0.95rem, 3.2vw, 1.15rem);
  padding: 0.55rem 0.35rem;
}

.mode-btn:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

.mode-hint {
  margin-bottom: 0.25rem;
  min-height: 1.4em;
}

.side-note {
  margin-bottom: 1rem;
  min-height: 1.4em;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.score-pill {
  background: #1e1e1e;
  border: 3px solid #1d4ed8;
  border-radius: 16px;
  padding: 0.7rem 0.4rem;
  text-align: center;
  box-shadow: 0 4px 0 #1e3a8a;
}

.score-pill.is-turn {
  border-color: #dbeafe;
  box-shadow:
    0 4px 0 #1e3a8a,
    0 0 16px rgba(96, 165, 250, 0.75);
}

.score-label {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 0.15rem;
}

.score-num {
  display: block;
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  line-height: 1.1;
}

.status {
  min-height: 2.8em;
  margin-bottom: 0.85rem;
  font-size: clamp(1.05rem, 3.5vw, 1.35rem);
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  max-width: 26rem;
  margin: 0 auto 1rem;
  background: linear-gradient(180deg, #1e1e1e 0%, #172554 100%);
  border-radius: 24px;
  padding: 0.75rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

body.lex-games-brand button.cell:not(.color-dot):not(.color-btn),
body.lex-games-brand button.cell:not(.color-dot):not(.color-btn):hover,
body.lex-games-brand button.cell:not(.color-dot):not(.color-btn):disabled {
  aspect-ratio: 1;
  min-height: 5.25rem;
  border-radius: 16px;
  background: #0b1220 !important;
  border: 3px solid #1d4ed8 !important;
  box-shadow:
    inset 0 0 0 2px rgba(30, 58, 138, 0.55),
    0 4px 0 #1e3a8a !important;
  color: inherit !important;
  -webkit-text-stroke: 0;
  letter-spacing: 0;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  transform: none;
  filter: none;
}

body.lex-games-brand button.cell:not(.color-dot):not(.color-btn):not(:disabled):hover {
  transform: translateY(-3px);
  filter: brightness(1.2);
}

body.lex-games-brand button.cell:not(.color-dot):not(.color-btn):disabled {
  cursor: default;
  opacity: 1;
}

body.lex-games-brand button.cell:focus-visible {
  outline: 3px solid #dbeafe;
  outline-offset: 3px;
}

body.lex-games-brand button.cell.win:not(.color-dot):not(.color-btn) {
  background: #172554 !important;
  border-color: #dbeafe !important;
  box-shadow: 0 0 18px rgba(96, 165, 250, 0.9) !important;
}

.glyph {
  font-family: "Fredoka One", "Comic Sans MS", cursive;
  font-size: clamp(3rem, 13vw, 4.6rem);
  line-height: 1;
  display: block;
  pointer-events: none;
}

body.lex-games-brand .cell.x .glyph {
  color: #eff6ff;
  -webkit-text-fill-color: #eff6ff;
  -webkit-text-stroke: 3px #1e3a8a;
  paint-order: stroke fill;
  filter: drop-shadow(0 3px 0 #1e3a8a);
}

body.lex-games-brand .cell.o .glyph {
  color: #93c5fd;
  -webkit-text-fill-color: #93c5fd;
  -webkit-text-stroke: 3px #1e3a8a;
  paint-order: stroke fill;
  filter: drop-shadow(0 3px 0 #1e3a8a);
}

.cell.fresh .glyph {
  animation: pop 0.35s ease;
}

.round-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.15rem;
  min-height: 3.25rem;
}

#next-round,
#start-over {
  min-height: 3.25rem;
  padding: 0.7rem 1.4rem;
  border-radius: 999px;
  font-size: 1.15rem;
  cursor: pointer;
}

#next-round[hidden] {
  display: none;
}

.rules {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1rem;
  text-align: center;
}

.rules li {
  background: rgba(30, 58, 138, 0.45);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.9rem;
}

.match-over {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: 1.5rem;
  z-index: 5;
}

.match-over[hidden] {
  display: none;
}

.match-title {
  text-align: center;
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  max-width: 16ch;
}

#play-again {
  min-height: 3.25rem;
  padding: 0.7rem 1.6rem;
  border-radius: 999px;
  font-size: 1.2rem;
  cursor: pointer;
}

@keyframes pop {
  0% {
    transform: scale(0.35);
  }
  60% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

@media (max-width: 640px) {
  .modes {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cell.fresh .glyph {
    animation: none;
  }

  body.lex-games-brand button.cell:not(.color-dot):not(.color-btn):not(:disabled):hover {
    transform: none;
  }
}
