    :root {
      --bg-top: #f5efe1;
      --bg-bottom: #d8e6f2;
      --panel: rgba(255, 252, 245, 0.94);
      --panel-border: rgba(73, 57, 40, 0.12);
      --board: #2d3436;
      --board-line: rgba(255, 255, 255, 0.22);
      --text: #2f2419;
      --muted: #705a43;
      --accent: #276ef1;
      --success: #4b9f56;
      --warning: #d87247;
      --shadow: 0 18px 44px rgba(69, 52, 33, 0.18);
    }

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

    html,
    body {
      min-height: 100%;
    }

    body {
      font-family: "Trebuchet MS", "Segoe UI", sans-serif;
      color: var(--text);
      background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.9), transparent 35%),
        linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
      user-select: none;
      -webkit-user-select: none;
      touch-action: manipulation;
    }

    button {
      font: inherit;
    }

    #appShell {
      min-height: 100vh;
      padding: 20px;
      display: flex;
      justify-content: center;
    }

    #appFrame {
      width: min(1160px, 100%);
      display: grid;
      gap: 14px;
      align-content: start;
    }

    #topBar {
      background: var(--panel);
      border: 1px solid var(--panel-border);
      border-radius: 18px;
      padding: 10px 14px;
      box-shadow: var(--shadow);
      display: block;
    }

    #titleRow {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      gap: 12px;
      flex-wrap: nowrap;
      overflow-x: auto;
    }

    .brandCluster {
      display: flex;
      align-items: center;
      gap: 10px;
      flex: 0 1 360px;
      min-width: 240px;
    }

    .menuWrap {
      display: none;
    }

    .brandLockup {
      display: flex;
      align-items: center;
      gap: 10px;
      min-width: 0;
      color: inherit;
      text-decoration: none;
    }

    .brandLogo {
      width: 46px;
      height: 46px;
      object-fit: contain;
      flex: 0 0 46px;
      filter: none;
    }

    .brandText {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      min-width: 0;
      gap: 2px;
    }

    #brand h1 {
      font-size: clamp(1.25rem, 1.7vw, 1.7rem);
      letter-spacing: 0.01em;
      line-height: 1;
      white-space: nowrap;
    }

    .titleShort {
      display: none;
    }

    #brand p {
      display: none;
    }

    #brand p,
    .status-card span,
    #messageText,
    .section-card p {
      color: var(--muted);
    }

    #statusGroup {
      display: flex;
      gap: 6px;
      flex-wrap: nowrap;
      align-items: center;
      justify-content: flex-end;
      flex: 1 1 auto;
      min-width: 0;
    }

    #toolbarActions {
      display: flex;
      gap: 6px;
      flex-wrap: nowrap;
      align-items: center;
      justify-content: flex-end;
    }

    #prevGameButton {
      white-space: nowrap;
    }

    #levelButtons,
    #toolbarActions #hintButton {
      display: none;
    }

    .status-card {
      min-width: 76px;
      padding: 6px 10px;
      border-radius: 12px;
      background: rgba(255, 255, 255, 0.75);
      border: 1px solid rgba(73, 57, 40, 0.08);
    }

    .status-card span {
      font-size: 0.8rem;
      line-height: 1.1;
    }

    .status-card strong {
      display: block;
      font-size: 0.95rem;
      line-height: 1.15;
    }

    #gameLayout {
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(460px, 0.92fr);
      gap: 18px;
      align-items: start;
    }

    .panel {
      background: var(--panel);
      border: 1px solid var(--panel-border);
      border-radius: 24px;
      box-shadow: var(--shadow);
    }

    #boardPanel {
      padding: 0;
      display: grid;
      justify-items: start;
      background: transparent;
      border: 0;
      border-radius: 0;
      box-shadow: none;
    }

    #boardFrame {
      width: 100%;
      display: flex;
      justify-content: flex-start;
      padding: 0;
      position: relative;
    }

    #board {
      --board-cols: 6;
      --board-rows: 5;
      position: relative;
      width: 480px;
      height: 400px;
      max-width: 100%;
      background: var(--board);
      border-radius: 24px;
      box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.4);
      overflow: hidden;
      touch-action: none;
    }

    .pause-overlay {
      position: absolute;
      inset: 0;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      border-radius: 24px;
      background: rgba(24, 20, 14, 0.96);
      color: white;
      font-size: clamp(1.1rem, 2vw, 1.5rem);
      font-weight: 800;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      text-align: center;
      gap: 10px;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.18s ease;
      z-index: 10;
    }

    .pause-overlay__time {
      font-size: clamp(1rem, 1.6vw, 1.2rem);
      font-weight: 700;
      letter-spacing: 0.04em;
      text-transform: none;
    }

    body.is-paused #gameLayout {
      pointer-events: none;
    }

    body.is-paused .pause-overlay {
      opacity: 1;
    }

    .board-cell {
      position: absolute;
      border: 1px solid var(--board-line);
      pointer-events: none;
    }

    .piece {
      position: absolute;
      touch-action: none;
      cursor: grab;
      filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.24));
    }

    .piece.selected {
      filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.24));
    }

    .piece.dragging {
      cursor: grabbing;
      z-index: 5000;
      filter: drop-shadow(0 16px 30px rgba(0, 0, 0, 0.32));
    }

    .piece.fixed-piece {
      cursor: default;
      opacity: 0.9;
    }

    .piece-cell {
      position: absolute;
      background: linear-gradient(180deg, color-mix(in srgb, var(--piece-color) 82%, white), var(--piece-color));
      border: 3px solid rgba(36, 27, 18, 0.88);
      border-radius: 14px;
      box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.28), inset 0 -3px 0 rgba(0, 0, 0, 0.18);
    }

    .piece-letter {
      position: absolute;
      left: 50%;
      top: 50%;
      font-weight: 900;
      color: rgba(33, 24, 17, 0.96);
      letter-spacing: 0.02em;
      text-transform: uppercase;
      transform-origin: center;
      pointer-events: none;
    }

    .piece.selected .piece-cell {
      border-color: #2f6ff0;
      box-shadow:
        0 0 0 3px rgba(47, 111, 240, 0.28),
        inset 0 3px 0 rgba(255, 255, 255, 0.28),
        inset 0 -3px 0 rgba(0, 0, 0, 0.18);
    }

    .piece-help-button {
      position: absolute;
      width: 24px;
      height: 24px;
      border-radius: 999px;
      border: 0;
      padding: 0;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      background: rgba(47, 36, 25, 0.88);
      color: white;
      font-size: 0.92rem;
      font-weight: 700;
      box-shadow: 0 6px 12px rgba(0, 0, 0, 0.22);
      z-index: 4;
    }

    .piece-rotate-popover {
      position: absolute;
      left: 50%;
      top: -12px;
      transform: translate(-50%, -100%);
      min-width: 176px;
      padding: 8px 10px;
      border-radius: 12px;
      background: rgba(47, 36, 25, 0.95);
      color: white;
      font-size: 0.82rem;
      line-height: 1.35;
      box-shadow: 0 12px 24px rgba(0, 0, 0, 0.24);
      pointer-events: none;
      z-index: 20;
    }

    .piece-rotate-popover strong {
      display: block;
      margin-bottom: 2px;
    }

    .fixed-piece .piece-cell {
      background: linear-gradient(180deg, #9ea7ac, #6e787e);
      border-color: rgba(34, 39, 42, 0.9);
      opacity: 0.95;
      border-style: dashed;
      box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.18), inset 0 -3px 0 rgba(0, 0, 0, 0.22);
    }

    #sidePanel {
      padding: 0;
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
      gap: 16px;
      align-content: start;
      background: transparent;
      border: 0;
      border-radius: 0;
      box-shadow: none;
    }

    #sidePanel > .section-card:first-child {
      grid-column: 1 / -1;
    }

    .section-card {
      padding: 16px;
      border-radius: 20px;
      background: rgba(255, 255, 255, 0.76);
      border: 1px solid rgba(73, 57, 40, 0.08);
      display: grid;
      gap: 12px;
    }

    .section-card h2 {
      font-size: 1.05rem;
    }

    .section-copy {
      color: var(--muted);
      font-size: 0.95rem;
      line-height: 1.5;
    }

    #tray {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
      gap: 10px;
      align-items: start;
      justify-items: stretch;
      align-content: start;
      min-height: 0;
    }

    .tray-piece-shell {
      min-width: 0;
      min-height: 0;
      width: 100%;
      padding: 10px 8px;
      border-radius: 18px;
      background: transparent;
      border: 1px solid transparent;
      display: flex;
      align-items: center;
      justify-content: center;
      position: relative;
      box-sizing: border-box;
      overflow: visible;
    }

    #targetPreview {
      display: grid;
      gap: 6px;
    }

    #targetPreview.is-hidden {
      opacity: 0.22;
      pointer-events: none;
      filter: blur(1px);
    }

    .target-cell {
      min-height: 38px;
      border-radius: 12px;
      background: rgba(255, 255, 255, 0.8);
      border: 1px solid rgba(73, 57, 40, 0.12);
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: 800;
      color: var(--text);
    }

    .target-cell.blocked {
      background: linear-gradient(180deg, #9ea7ac, #6e787e);
      border-color: rgba(34, 39, 42, 0.9);
      color: transparent;
      border-style: dashed;
    }

    .target-cell.path-cell {
      background: rgba(255, 237, 186, 0.92);
      border-color: rgba(202, 148, 49, 0.45);
    }

    .target-cell.space-cell {
      background:
        linear-gradient(135deg, transparent 42%, rgba(47, 36, 25, 0.18) 42%, rgba(47, 36, 25, 0.18) 58%, transparent 58%),
        rgba(255, 255, 255, 0.58);
      border-color: rgba(73, 57, 40, 0.18);
    }

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

    .mini-stat {
      padding: 12px 14px;
      border-radius: 16px;
      background: rgba(255, 255, 255, 0.7);
      border: 1px solid rgba(73, 57, 40, 0.08);
    }

    .mini-stat span {
      display: block;
      color: var(--muted);
      font-size: 0.84rem;
      margin-bottom: 4px;
    }

    .mini-stat strong {
      font-size: 1rem;
    }

    .helperActions {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
    }

    .helperActions .btn {
      flex: 1 1 160px;
    }

    #clueLockNote {
      padding: 10px 12px;
      border-radius: 14px;
      background: rgba(39, 110, 241, 0.08);
      border: 1px solid rgba(39, 110, 241, 0.12);
      color: var(--muted);
      font-size: 0.9rem;
      line-height: 1.45;
    }

    .btn {
      border: 0;
      border-radius: 14px;
      padding: 10px 16px;
      font-weight: 800;
      color: white;
      cursor: pointer;
      box-shadow: 0 10px 18px rgba(69, 52, 33, 0.14);
      transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
    }

    .btn:hover {
      transform: translateY(-1px);
      box-shadow: 0 14px 24px rgba(0, 0, 0, 0.16);
    }

    .btn:disabled {
      opacity: 0.55;
      cursor: not-allowed;
      transform: none;
      box-shadow: none;
    }

    .btn-primary {
      background: linear-gradient(135deg, #276ef1, #4ea3ff);
    }

    .btn-success {
      background: linear-gradient(135deg, #4b9f56, #73c47b);
    }

    .btn-warning {
      background: linear-gradient(135deg, #d87247, #ef9d61);
    }

    .mobileActionBar {
      position: sticky;
      bottom: 0;
      z-index: 30;
      display: none;
      gap: 8px;
      padding: 10px;
      background: rgba(255, 252, 245, 0.96);
      border: 1px solid rgba(73, 57, 40, 0.12);
      border-radius: 18px 18px 0 0;
      box-shadow: 0 -10px 28px rgba(69, 52, 33, 0.16);
      backdrop-filter: blur(12px);
    }

    .mobileActionBar .btn {
      flex: 1 1 0;
      min-width: 0;
      justify-content: center;
    }

    .btn-ghost {
      background: white;
      color: var(--text);
      border: 1px solid rgba(73, 57, 40, 0.15);
      box-shadow: none;
    }

    .icon-btn {
      width: 44px;
      min-width: 44px;
      height: 44px;
      border-radius: 14px;
      padding: 0;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 1.05rem;
      line-height: 1;
    }

    #primaryButtons {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
    }

    #prefsOverlay,
    #profileOverlay {
      position: fixed;
      inset: 0;
      display: none;
      align-items: center;
      justify-content: center;
      background: rgba(31, 20, 12, 0.42);
      padding: 20px;
      z-index: 8000;
    }

    #prefsCard {
      width: min(420px, 100%);
      background: rgba(255, 252, 247, 0.98);
      border-radius: 24px;
      border: 1px solid rgba(73, 57, 40, 0.12);
      box-shadow: 0 24px 60px rgba(0, 0, 0, 0.24);
      padding: 18px;
      display: grid;
      gap: 14px;
    }

    #prefsCard p {
      color: var(--muted);
    }

    .prefs-grid {
      display: grid;
      gap: 10px;
    }

    .prefs-grid label {
      display: flex;
      align-items: center;
      gap: 10px;
      color: var(--text);
    }

    #profileOverlay input {
      width: 100%;
      padding: 10px 12px;
      border-radius: 12px;
      border: 1px solid rgba(73, 57, 40, 0.16);
      font: inherit;
    }

    #prefsActions {
      display: flex;
      justify-content: flex-end;
      gap: 10px;
      flex-wrap: wrap;
    }

    .hint-cell {
      position: absolute;
      border: 4px solid rgba(255, 214, 10, 0.98);
      border-radius: 16px;
      background: transparent;
      pointer-events: none;
      z-index: 4000;
      box-shadow: 0 0 0 2px rgba(35, 27, 16, 0.5), 0 0 18px rgba(255, 214, 10, 0.45);
      animation: hintPulse 0.9s ease-in-out infinite alternate;
    }

    @keyframes hintPulse {
      from {
        opacity: 0.62;
        transform: scale(0.97);
      }

      to {
        opacity: 1;
        transform: scale(1);
      }
    }

    @media (max-width: 920px) {
      #gameLayout {
        grid-template-columns: 1fr;
      }

      #sidePanel {
        grid-template-columns: 1fr;
      }

      #tray {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
    }

    @media (max-width: 640px) {
      #appShell {
        padding: 12px;
      }

      #topBar,
      #boardPanel,
      #sidePanel {
        border-radius: 20px;
      }

      #titleRow {
        align-items: flex-start;
      }

      .brandCluster {
        flex-basis: 100%;
        min-width: 0;
      }

      .brandLogo {
        width: 42px;
        height: 42px;
        flex-basis: 42px;
      }

      #statusGroup {
        width: 100%;
        justify-content: flex-start;
      }

      #tray {
        grid-template-columns: 1fr 1fr;
      }

        .btn {
          width: 100%;
        }
      }

    .menuWrap {
      position: relative;
      flex: 0 0 auto;
    }

    .menuToggleButton {
      width: 42px;
      height: 42px;
      border-radius: 14px;
      border: 1px solid rgba(73, 57, 40, 0.14);
      background: rgba(255, 255, 255, 0.74);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
    }

    .menuToggleButton span,
    .menuToggleButton span::before,
    .menuToggleButton span::after {
      display: block;
      width: 16px;
      height: 3px;
      border-radius: 999px;
      background: #2f2419;
      content: "";
    }

    .menuToggleButton span {
      position: relative;
    }

    .menuToggleButton span::before {
      position: absolute;
      top: -6px;
      left: 0;
    }

    .menuToggleButton span::after {
      position: absolute;
      top: 6px;
      left: 0;
    }

    .menuPanel {
      position: absolute;
      top: calc(100% + 10px);
      left: 0;
      min-width: 220px;
      padding: 8px;
      border-radius: 18px;
      border: 1px solid rgba(73, 57, 40, 0.14);
      background: rgba(255, 252, 245, 0.99);
      box-shadow: 0 18px 36px rgba(69, 52, 33, 0.22);
      display: none;
      z-index: 30;
    }

    .menuPanel.open {
      display: grid;
      gap: 6px;
    }

    .menuItem {
      width: 100%;
      padding: 11px 12px;
      border: 0;
      border-radius: 12px;
      background: rgba(47, 36, 25, 0.08);
      color: var(--text);
      text-align: left;
      font-size: 14px;
      font-weight: 800;
      cursor: pointer;
    }

    .details-card summary {
      list-style: none;
      cursor: pointer;
      font-size: 1rem;
      font-weight: 800;
    }

    .details-card summary::-webkit-details-marker {
      display: none;
    }

    .gameOverlay {
      position: fixed;
      inset: 0;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 16px;
      background: rgba(31, 20, 12, 0.42);
      z-index: 9000;
    }

    .gameOverlayCard {
      width: min(420px, 100%);
      padding: 20px;
      border-radius: 24px;
      background: rgba(255, 252, 247, 0.98);
      border: 1px solid rgba(73, 57, 40, 0.12);
      box-shadow: 0 24px 60px rgba(0, 0, 0, 0.24);
      display: grid;
      gap: 12px;
    }

    .gameOverlayCard h2 {
      font-size: 1.25rem;
    }

    .gameOverlayCard p {
      color: var(--muted);
      line-height: 1.5;
    }

    .gameOverlayActions {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
      justify-content: flex-end;
    }

    /* Mobile layout begins */
    @media (max-width: 900px) {
      #gameLayout {
        grid-template-columns: 1fr;
      }
    }

    /* Mobile layout begins */
    @media (max-width: 760px) {
      :root {
        --toolbar-height: 72px;
        --bottom-bar-height: 72px;
      }

      body {
        padding-bottom: calc(var(--bottom-bar-height) + env(safe-area-inset-bottom) + 18px);
      }

      #appShell {
        padding: 10px;
      }

      #topBar {
        padding: 10px 12px;
      }

      #titleRow {
        align-items: center;
      }

      #statusGroup {
        width: auto;
        justify-content: flex-end;
      }

      .brandCluster {
        min-width: 0;
        flex: 0 1 auto;
      }

      .brandLogo {
        width: 34px;
        height: 34px;
        flex-basis: 34px;
      }

      #brand h1 {
        font-size: 1.05rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .brandText {
        display: block;
      }

      .titleFull {
        display: none;
      }

      .titleShort {
        display: inline;
      }

      #toolbarActions {
        width: auto;
        display: flex;
        gap: 8px;
      }

      #toolbarActions #resetButton {
        display: none;
      }

      #toolbarActions #pauseButton {
        display: none;
      }

      .status-card {
        min-width: 0;
        padding: 4px 6px;
      }

      .status-card span {
        display: none;
      }

      #boardFrame {
        justify-content: center;
      }

      #board {
        width: min(92vw, 390px);
        height: calc(min(92vw, 390px) * 0.8334);
        max-width: 100%;
      }

      #sidePanel {
        grid-template-columns: 1fr;
        gap: 10px;
      }

      .section-card {
        padding: 14px;
      }

      .section-card:first-child .section-copy {
        display: none;
      }

      #tray {
        display: flex;
        flex-wrap: nowrap;
        align-items: flex-start;
        gap: 12px;
        overflow-x: auto;
        overflow-y: hidden;
        min-height: 150px;
        max-height: 175px;
        padding: 4px 2px 10px;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
      }

      .tray-piece-shell {
        flex: 0 0 auto;
        width: auto;
        min-width: 104px;
        scroll-snap-align: start;
      }

      .section-card:first-child {
        overflow: hidden;
      }

      #targetPanel {
        order: 2;
      }

      #detailsPanel {
        order: 3;
      }

      #targetPanel,
      #detailsPanel {
        display: block;
      }

      #targetPanel:not([open]) #targetPreview,
      #targetPanel:not([open]) #phraseText,
      #targetPanel:not([open]) #clueLockNote {
        display: none;
      }

      .mobileActionBar {
        display: flex;
      }

    }

    @media (max-width: 560px) {
      .status-card {
        min-width: 64px;
      }
    }

    @media (max-height: 760px) {
      #appShell {
        padding: 14px;
      }
    }
  

