:root {
  color-scheme: light;
  --ink: #19202a;
  --muted: #66717f;
  --paper: #fffaf0;
  --surface: #ffffff;
  --line: #d9d2c3;
  --accent: #0b6b68;
  --accent-strong: #064d4a;
  --sun: #f5b84b;
  --danger: #be3a34;
  --success: #26724f;
  --shadow: 0 24px 80px rgba(31, 39, 49, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background:
    radial-gradient(circle at 18% 12%, rgba(245, 184, 75, 0.24), transparent 28rem),
    linear-gradient(135deg, #e9f4ef 0%, var(--paper) 46%, #e8eef7 100%);
}

button,
select {
  font: inherit;
}

.game-shell {
  display: grid;
  min-height: 100vh;
  padding: 32px;
  align-items: start;
  justify-items: center;
}

.stage {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  width: min(1120px, 100%);
  overflow: hidden;
  border: 1px solid rgba(25, 32, 42, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.side-menu {
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 28px 20px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
}

.side-menu-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 4px;
  padding: 0 12px;
  color: var(--accent);
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.side-menu-title span {
  font-size: 1.5rem;
  letter-spacing: normal;
  text-transform: none;
}

.side-menu-group {
  margin: 12px 0 0;
  padding: 0 12px;
  color: var(--muted);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.side-menu-link {
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 16px;
}

.side-menu-link:hover {
  background: #f2fbf8;
  color: var(--accent-strong);
}

.side-menu-link.is-current {
  color: var(--accent);
  background: #f2fbf8;
}

.stage-main {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px clamp(22px, 3vw, 36px);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.9rem);
  line-height: 0.95;
}

.icon-button {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-strong);
  background: var(--surface);
  cursor: pointer;
  text-decoration: none;
  font-size: 1.6rem;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: #f2fbf8;
}

.home-board {
  display: grid;
  gap: 24px;
  padding: clamp(22px, 4vw, 44px);
}

.home-intro {
  margin: 0;
  color: var(--accent);
  font-size: 1.4rem;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.home-card {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  color: var(--ink);
  background: var(--surface);
  text-decoration: none;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.home-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(11, 107, 104, 0.14);
}

.home-card-icon {
  width: 36px;
  height: 40px;
  fill: none;
  stroke: var(--accent-strong);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 9;
}

.home-card-title {
  font-weight: 900;
  font-size: 1.1rem;
}

.home-card-desc {
  color: var(--muted);
  font-size: 0.9rem;
}

.game-board {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  min-height: 520px;
}

.drawing-panel,
.play-panel {
  padding: clamp(22px, 4vw, 44px);
}

.drawing-panel {
  position: relative;
  display: grid;
  align-content: center;
  gap: 24px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.55)),
    repeating-linear-gradient(0deg, transparent 0 28px, rgba(11, 107, 104, 0.08) 29px 30px);
}

.fail-sticker,
.success-sticker {
  position: absolute;
  top: 34px;
  right: 34px;
  z-index: 2;
  rotate: 12deg;
  scale: 0.82;
  opacity: 0;
  border: 5px solid var(--danger);
  border-radius: 8px;
  padding: 8px 16px 10px;
  color: var(--danger);
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(190, 58, 52, 0.22);
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 950;
  line-height: 1;
  pointer-events: none;
  text-transform: uppercase;
  transition:
    opacity 180ms ease,
    scale 180ms ease,
    rotate 180ms ease;
}

.fail-sticker {
  border-color: var(--danger);
  color: var(--danger);
  box-shadow: 0 10px 24px rgba(190, 58, 52, 0.22);
}

.success-sticker {
  display: grid;
  width: clamp(68px, 10vw, 96px);
  height: clamp(68px, 10vw, 96px);
  place-items: center;
  border-color: var(--success);
  border-radius: 50%;
  color: var(--success);
  box-shadow: 0 10px 24px rgba(38, 114, 79, 0.22);
  font-size: clamp(2.4rem, 6vw, 4rem);
}

.stage.is-lost .fail-sticker {
  opacity: 1;
  rotate: -8deg;
  scale: 1;
}

.stage.is-won .success-sticker {
  opacity: 1;
  rotate: -8deg;
  scale: 1;
}

.hangman {
  width: min(100%, 360px);
  margin-inline: auto;
  aspect-ratio: 12 / 13;
}

.gallows,
.body-part {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 9;
}

.gallows {
  stroke: #4b5563;
}

.stage.is-building-gallows .gallows {
  opacity: 0;
  transform: scale(0.98);
  transform-origin: center;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.stage.is-building-gallows .gallows.is-visible {
  opacity: 1;
  transform: scale(1);
}

.brace {
  stroke-width: 7;
}

.body-part {
  opacity: 0;
  stroke: #4b5563;
  transform: scale(0.95);
  transform-origin: center;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.body-part.is-visible {
  opacity: 1;
  transform: scale(1);
}

.status-card {
  border-left: 5px solid var(--sun);
  border-radius: 8px;
  padding: 16px 18px;
  background: var(--surface);
}

.status-card span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-card strong {
  display: block;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  line-height: 1.25;
}

.play-panel {
  display: grid;
  align-content: center;
  gap: 24px;
  background: rgba(255, 255, 255, 0.52);
}

.settings {
  display: grid;
  gap: 12px;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.controls label {
  color: var(--muted);
  font-weight: 800;
}

select {
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 36px 10px 12px;
  color: var(--ink);
  background: var(--surface);
}

.word {
  display: flex;
  min-height: 76px;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(6px, 1.2vw, 12px);
  flex-wrap: wrap;
}

.letter-slot {
  display: grid;
  min-width: clamp(26px, 5vw, 46px);
  height: clamp(44px, 8vw, 64px);
  place-items: center;
  border-bottom: 4px solid var(--accent);
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 900;
  text-transform: uppercase;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stats div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--surface);
}

.stats span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stats strong {
  display: block;
  margin-top: 4px;
  font-size: 1.35rem;
}

.keyboard {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 8px;
}

.key {
  min-width: 0;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  font-weight: 900;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease,
    color 120ms ease;
}

.key:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.key:disabled {
  cursor: not-allowed;
}

.key.is-correct {
  border-color: var(--success);
  color: #ffffff;
  background: var(--success);
}

.key.is-wrong {
  border-color: var(--danger);
  color: #ffffff;
  background: var(--danger);
}

.hint {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
}

.stage.is-won .status-card {
  border-left-color: var(--success);
}

.stage.is-lost .status-card {
  border-left-color: var(--danger);
}

.ttt-board-area {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(240px, 0.7fr);
  gap: clamp(22px, 4vw, 44px);
  padding: clamp(22px, 4vw, 44px);
}

.ttt-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1;
  margin-inline: auto;
}

.ttt-cell {
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 900;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease;
}

.ttt-cell:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.ttt-cell:disabled {
  cursor: not-allowed;
}

.ttt-cell.is-x {
  color: var(--accent);
}

.ttt-cell.is-o {
  color: var(--danger);
}

.ttt-cell.is-winning {
  border-color: var(--success);
  background: #f2fbf8;
}

.ttt-side {
  display: grid;
  align-content: start;
  gap: 24px;
}

@media (max-width: 780px) {
  .ttt-board-area {
    grid-template-columns: 1fr;
  }

  .game-shell {
    padding: 16px;
  }

  .stage {
    grid-template-columns: 1fr;
  }

  .side-menu {
    grid-auto-flow: column;
    justify-content: start;
    gap: 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-menu-title {
    display: none;
  }

  .topbar {
    padding: 22px;
  }

  .game-board {
    grid-template-columns: 1fr;
  }

  .drawing-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .keyboard {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 440px) {
  .stats {
    grid-template-columns: 1fr;
  }

  .controls {
    display: grid;
    align-items: stretch;
  }

  select {
    width: 100%;
  }

  .keyboard {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
