﻿:root {
      color-scheme: light;
      --bg: #f5f2ea;
      --panel: #fffaf0;
      --ink: #26312d;
      --muted: #6c756f;
      --tile: #f8c65b;
      --tile-edge: #a8662b;
      --tile-selected: #dfaa3a;
      --tile-selected-edge: #704c12;
      --line: #c8323b;
      --button: #26312d;
      --button-soft: #e9e0ce;
      --shadow: 0 18px 46px rgba(38, 49, 45, 0.16);
    }

    * {
      box-sizing: border-box;
    }

    body {
      margin: 0;
      min-height: 100vh;
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      background:
        radial-gradient(circle at top left, rgba(47, 128, 111, 0.18), transparent 34rem),
        linear-gradient(145deg, #fbf7ef 0%, var(--bg) 52%, #e5efe8 100%);
      color: var(--ink);
    }

    .app {
      width: min(1120px, 100%);
      min-height: 100vh;
      margin: 0 auto;
      padding: clamp(16px, 4vw, 40px);
      display: grid;
      grid-template-columns: minmax(0, 1fr) 320px;
      gap: clamp(16px, 3vw, 32px);
      align-items: stretch;
    }

    .game {
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 16px;
    }

    header {
      display: flex;
      align-items: end;
      justify-content: space-between;
      gap: 16px;
    }

    h1 {
      margin: 0;
      font-size: clamp(2.1rem, 6vw, 4.6rem);
      line-height: 0.92;
      letter-spacing: 0;
    }

    .score {
      min-width: 92px;
      text-align: right;
      color: var(--muted);
      font-weight: 700;
      display: grid;
      gap: 4px;
    }

    #streak-label {
      font-size: 0.86rem;
      color: var(--ink);
    }

    .current {
      min-height: 58px;
      padding: 10px 14px;
      border: 2px solid rgba(38, 49, 45, 0.16);
      border-radius: 8px;
      background: rgba(255, 250, 240, 0.72);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: clamp(1.5rem, 5vw, 2.6rem);
      font-weight: 850;
      letter-spacing: 0.08em;
      color: var(--tile-selected-edge);
      box-shadow: 0 10px 28px rgba(38, 49, 45, 0.08);
      cursor: pointer;
    }

    .current:empty::before {
      content: " ";
    }

    .current.selecting {
      color: var(--tile);
    }

    .current.valid-submit {
      color: #1f7a4d;
    }

    .current.invalid-submit {
      color: #a1262d;
    }

    .current.repeat-submit {
      color: var(--tile);
    }

    .points-pop {
      position: fixed;
      z-index: 50;
      padding: 8px 12px;
      border-radius: 999px;
      background: #26312d;
      color: white;
      font-weight: 900;
      pointer-events: none;
      box-shadow: 0 12px 26px rgba(38, 49, 45, 0.24);
      animation: points-rise 1300ms ease forwards;
    }

    @keyframes points-rise {
      0% {
        opacity: 0;
        transform: translate(-50%, 8px) scale(0.88);
      }
      12% {
        opacity: 1;
        transform: translate(-50%, -18px) scale(1.05);
      }
      62% {
        opacity: 1;
        transform: translate(-50%, -26px) scale(1.05);
      }
      100% {
        opacity: 0;
        transform: translate(-50%, -48px) scale(1.08);
      }
    }

    .progress-panel {
      padding: 12px 14px;
      border: 2px solid rgba(38, 49, 45, 0.12);
      border-radius: 8px;
      background: rgba(255, 250, 240, 0.74);
      box-shadow: 0 10px 28px rgba(38, 49, 45, 0.08);
      cursor: pointer;
    }

    .progress-meta {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 8px;
      color: var(--muted);
      font-weight: 800;
      font-size: 0.9rem;
    }

    .progress-track {
      position: relative;
      height: 14px;
      border-radius: 999px;
      background: rgba(38, 49, 45, 0.14);
      overflow: visible;
    }

    .progress-fill {
      position: absolute;
      inset: 0 auto 0 0;
      width: 0%;
      border-radius: inherit;
      background: linear-gradient(90deg, #2f806f, #c8333a);
      transition: width 220ms ease;
    }

    .star {
      position: absolute;
      top: 50%;
      width: 28px;
      height: 28px;
      border-radius: 50%;
      display: grid;
      place-items: center;
      transform: translate(-50%, -50%);
      background: #fffaf0;
      border: 2px solid rgba(38, 49, 45, 0.28);
      color: rgba(38, 49, 45, 0.46);
      font-size: 1rem;
      font-weight: 900;
      transition: background 180ms ease, color 180ms ease, border 180ms ease, transform 180ms ease;
    }

    .star.unlocked {
      background: #f8c65b;
      border-color: #a8662b;
      color: #34250d;
      transform: translate(-50%, -50%) scale(1.08);
    }

    .board-shell {
      position: relative;
      flex: 1;
      min-height: min(68vh, 660px);
      border-radius: 8px;
      background:
        linear-gradient(180deg, rgba(255, 250, 240, 0.9), rgba(255, 250, 240, 0.58)),
        repeating-linear-gradient(30deg, rgba(38, 49, 45, 0.035) 0 1px, transparent 1px 24px);
      box-shadow: var(--shadow);
      overflow: hidden;
      touch-action: none;
      user-select: none;
    }

    .board {
      position: absolute;
      inset: clamp(12px, 3vw, 28px);
      touch-action: none;
    }

    .tile-layer {
      position: absolute;
      inset: 0;
      z-index: 5;
      transform-origin: 50% 50%;
    }

    .paths {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      pointer-events: none;
      overflow: visible;
      z-index: 6;
    }

    .label-overlay {
      position: absolute;
      inset: 0;
      pointer-events: none;
      z-index: 8;
      transform-origin: 50% 50%;
    }

    .tile-label {
      position: absolute;
      display: grid;
      place-items: center;
      color: #34250d;
      font: 900 var(--letter-size, 2rem) / 1 Inter, ui-sans-serif, system-ui, sans-serif;
      transform: translate(-50%, -50%) rotate(var(--hex-rotation));
    }

    .tile-label .hex-content {
      position: absolute;
      inset: 0;
      opacity: 1;
    }

    .path-blob,
    .path-node,
    .path-cursor {
      fill: var(--line);
      opacity: 1;
    }

    .hex {
      position: absolute;
      display: grid;
      place-items: center;
      border: 0;
      padding: 0;
      background: var(--tile);
      color: #34250d;
      clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
      font: 900 var(--letter-size, 2rem) / 1 Inter, ui-sans-serif, system-ui, sans-serif;
      cursor: pointer;
      z-index: 5;
      --hex-rotation: 0deg;
      --letter-rotation: 0deg;
      transform: translate(-50%, -50%) rotate(var(--hex-rotation));
      transition: transform 120ms ease, background 120ms ease, color 120ms ease, filter 120ms ease;
      filter:
        drop-shadow(0 4px 0 var(--tile-edge))
        drop-shadow(0 11px 12px rgba(38, 49, 45, 0.16));
      touch-action: none;
    }

    .hex:hover {
      filter:
        drop-shadow(0 4px 0 var(--tile-edge))
        drop-shadow(0 13px 13px rgba(38, 49, 45, 0.18));
    }

    .hex-content {
      position: absolute;
      inset: 0;
      display: grid;
      place-items: center;
      transform: rotate(var(--letter-rotation));
      pointer-events: none;
      z-index: 2;
      opacity: 0;
    }

    .hex-letter {
      display: block;
    }

    .hex-count {
      position: absolute;
      min-width: 1em;
      height: 1em;
      display: grid;
      place-items: center;
      font-size: calc(var(--letter-size, 2rem) * 0.38);
      font-weight: 900;
      line-height: 1;
      pointer-events: none;
    }

    .hex-count.start-count {
      left: 20%;
      bottom: 10%;
      color: var(--line);
    }

    .hex-count.include-count {
      right: 20%;
      bottom: 10%;
      color: #596168;
    }

    .hex.completed {
      opacity: 0.3;
      filter: grayscale(0.7) drop-shadow(0 3px 0 rgba(38, 49, 45, 0.24));
    }

    .hex.unused {
      opacity: 0;
      pointer-events: none;
    }

    .hex.selected {
      z-index: 5;
      filter:
        drop-shadow(0 4px 0 var(--tile-edge))
        drop-shadow(0 15px 14px rgba(38, 49, 45, 0.22));
    }

    .tile-label.selected-label {
      color: white;
    }

    .tile-label.completed-label {
      color: #8a8f8a;
    }

    .tile-label.completed-label.selected-label {
      color: white;
    }

    .hex.just-found {
      animation: found-pop 260ms ease;
    }

    @keyframes found-pop {
      50% {
        filter:
          drop-shadow(0 4px 0 var(--tile-edge))
          drop-shadow(0 17px 17px rgba(38, 49, 45, 0.24));
      }
    }

    .hex.selected.just-found {
      animation: selected-found-pop 260ms ease;
    }

    @keyframes selected-found-pop {
      50% {
        filter:
          drop-shadow(0 4px 0 var(--tile-edge))
          drop-shadow(0 17px 17px rgba(38, 49, 45, 0.26));
      }
    }

    aside {
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 14px;
    }

    .controls,
    .found-panel {
      padding: 16px;
      border-radius: 8px;
      background: rgba(255, 250, 240, 0.84);
      box-shadow: var(--shadow);
    }

    .status {
      min-height: 24px;
      margin-bottom: 12px;
      color: var(--muted);
      font-weight: 700;
    }

    .result-card {
      display: grid;
      grid-template-columns: 1fr;
      gap: 10px;
      border-top: 1px solid rgba(38, 49, 45, 0.12);
      padding-top: 12px;
    }

    .result-card div {
      display: flex;
      align-items: baseline;
      justify-content: space-between;
      gap: 12px;
      color: var(--muted);
      font-weight: 800;
    }

    .result-card strong {
      color: var(--ink);
      font-size: 1.6rem;
      line-height: 1;
    }

    .buttons {
      display: grid;
      grid-template-columns: 1fr;
      gap: 10px;
    }

    button.action {
      min-height: 42px;
      border: 0;
      border-radius: 8px;
      padding: 10px 12px;
      font-weight: 850;
      color: white;
      background: var(--button);
      cursor: pointer;
    }

    button.action.secondary {
      color: var(--ink);
      background: var(--button-soft);
    }

    .rotate-board {
      position: absolute;
      left: clamp(12px, 3vw, 24px);
      bottom: clamp(12px, 3vw, 24px);
      width: 52px;
      height: 52px;
      border: 0;
      border-radius: 50%;
      display: grid;
      place-items: center;
      background: rgba(255, 250, 240, 0.9);
      color: var(--ink);
      box-shadow: 0 10px 22px rgba(38, 49, 45, 0.18);
      cursor: pointer;
      font-size: 1.8rem;
      font-weight: 900;
      line-height: 1;
      z-index: 10;
    }

    .rotate-board:active {
      transform: scale(0.96);
    }

    .found-panel {
      width: min(620px, calc(100vw - 28px));
      max-height: min(720px, calc(100svh - 40px));
      overflow: auto;
      background: var(--panel);
    }

    .found-head {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 12px;
      color: var(--muted);
      font-weight: 800;
    }

    .found-list {
      display: grid;
      gap: 14px;
      min-height: 90px;
    }

    .word-chip {
      border: 0;
      border-radius: 999px;
      padding: 7px 10px;
      background: #dbe8e1;
      color: #193b34;
      font-weight: 850;
      letter-spacing: 0.04em;
      font-size: 0.86rem;
    }

    button.word-chip {
      cursor: pointer;
    }

    .word-chip.missing {
      background: rgba(38, 49, 45, 0.08);
      color: rgba(38, 49, 45, 0.28);
    }

    .word-chip.hint {
      color: rgba(38, 49, 45, 0.58);
    }

    .word-group {
      display: grid;
      gap: 8px;
    }

    .word-group.bonus-group {
      padding-top: 14px;
      border-top: 1px solid rgba(38, 49, 45, 0.14);
    }

    .word-group-head {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      color: var(--muted);
      font-size: 0.88rem;
      font-weight: 850;
    }

    .word-slots {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
    }

    .word-chip.bonus-chip {
      background: #eee5d3;
      color: #596168;
    }

    .word-chip.bonus-chip.missing {
      background: rgba(38, 49, 45, 0.06);
      color: rgba(38, 49, 45, 0.24);
    }

    .found-modal {
      position: fixed;
      inset: 0;
      z-index: 80;
      display: none;
      place-items: center;
      padding: 20px;
      background: rgba(38, 49, 45, 0.32);
    }

    .found-modal.open {
      display: grid;
    }

    .definition-card {
      width: min(420px, calc(100vw - 28px));
      padding: 18px;
      border-radius: 8px;
      background: var(--panel);
      box-shadow: var(--shadow);
    }

    .definition-card h2 {
      margin: 0 0 8px;
      font-size: 1.4rem;
      letter-spacing: 0.04em;
    }

    .definition-card p {
      margin: 0 0 16px;
      color: var(--muted);
      line-height: 1.5;
      font-weight: 650;
    }

    .close-popup {
      min-height: 34px;
      padding: 7px 10px;
    }

    .test-words {
      margin-top: 14px;
      color: var(--muted);
      font-size: 0.88rem;
      line-height: 1.45;
    }

    .hint-tools {
      display: none;
      margin-top: 16px;
      padding-top: 14px;
      border-top: 1px solid rgba(38, 49, 45, 0.14);
    }

    .hint-tools.unlocked {
      display: block;
    }

    .hint-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 12px;
      margin-bottom: 10px;
      color: var(--muted);
      font-weight: 800;
    }

    .hint-list {
      display: grid;
      gap: 7px;
    }

    .hint-row {
      display: flex;
      justify-content: space-between;
      gap: 10px;
      border-radius: 8px;
      padding: 8px 10px;
      background: rgba(219, 232, 225, 0.78);
      color: #193b34;
      font-weight: 850;
    }

    @media (max-width: 780px) {
      .app {
        min-height: 100svh;
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        padding: 14px;
      }

      header {
        align-items: center;
      }

      .score {
        min-width: 70px;
      }

      .current {
        min-height: 50px;
      }

      .board-shell {
        min-height: 54svh;
      }

      aside {
        display: grid;
        grid-template-columns: 1fr;
      }

      .found-panel {
        min-height: 150px;
      }

      .test-words {
        display: none;
      }
    }

    @media (max-width: 420px) {
      .app {
        padding: 10px;
        gap: 10px;
      }

      .board-shell {
        min-height: 50svh;
      }

      .controls,
      .found-panel {
        padding: 12px;
      }
    }
