
  :root {
    --ink: #4a3226;
    --muted: #977963;
    --accent: #ff8a3c;
    --accent-deep: #e2741f;
    --danger: #ef5b4c;
    --card: rgba(255, 252, 245, 0.86);
    --line: rgba(190, 120, 55, 0.2);
    --shadow: 0 18px 46px rgba(150, 90, 40, 0.15);
  }
  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  html, body { height: 100%; }
  body {
    margin: 0;
    overflow: hidden;
    color: var(--ink);
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
    background:
      radial-gradient(1000px 620px at 8% -10%, #fff4e1 0%, rgba(255, 244, 225, 0) 60%),
      radial-gradient(920px 660px at 106% 12%, #ffd9b9 0%, rgba(255, 217, 185, 0) 58%),
      linear-gradient(165deg, #fff8ee 0%, #ffe9d3 52%, #ffddc0 100%);
    user-select: none;
    -webkit-user-select: none;
  }
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cg fill='%23d98b45' opacity='0.09'%3E%3Cellipse cx='90' cy='106' rx='19' ry='15'/%3E%3Ccircle cx='69' cy='77' r='7.5'/%3E%3Ccircle cx='84' cy='68' r='7.5'/%3E%3Ccircle cx='99' cy='70' r='7.5'/%3E%3Ccircle cx='111' cy='82' r='6.5'/%3E%3C/g%3E%3C/svg%3E");
    background-size: 180px 180px;
    opacity: 0.7;
  }
  button { font-family: inherit; }
  button:focus-visible { outline: 3px solid rgba(255, 150, 60, 0.5); outline-offset: 2px; }
  [hidden] { display: none !important; }

  .game {
    position: relative;
    z-index: 1;
    width: min(100%, 1060px);
    height: 100vh;
    height: 100dvh;
    margin: 0 auto;
    padding: clamp(8px, 1.6vh, 16px) clamp(10px, 2.4vw, 24px) max(clamp(8px, 1.6vh, 16px), env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: clamp(5px, 1.1vh, 11px);
  }

  .top { flex: 0 0 auto; }
  .hud {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: clamp(8px, 1.6vw, 18px);
  }
  .hud-left {
    justify-self: start;
    display: flex;
    align-items: center;
    gap: clamp(6px, 1vw, 10px);
    min-width: 0;
  }
  .hud-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: clamp(38px, 5.2vh, 46px);
    padding: 0 clamp(10px, 1.7vw, 16px);
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(150, 90, 40, 0.08);
    white-space: nowrap;
  }
  .level-chip { gap: 3px; font-size: clamp(11px, 1.7vh, 14px); font-weight: 600; color: #86664f; }
  .level-chip b { color: var(--accent-deep); font-size: 1.18em; }
  .score-chip { gap: 7px; }
  .score-label { font-size: clamp(9px, 1.4vh, 12px); color: var(--muted); letter-spacing: 0.1em; }
  .score-val {
    font-size: clamp(17px, 2.6vh, 23px);
    line-height: 1;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: #573826;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
    transition: transform 0.2s ease;
  }
  .score-val.bump { animation: scorePop 0.38s ease; }

  .clock-slot {
    position: relative;
    justify-self: center;
    display: flex;
    justify-content: center;
    min-width: 0;
  }
  .clock-widget {
    position: relative;
    gap: 7px;
  }
  .clock-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: clamp(22px, 3.2vh, 28px);
    line-height: 0;
    transform-origin: 50% 85%;
  }
  .clock-svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    filter: drop-shadow(0 2px 2px rgba(150, 90, 40, 0.12));
    transition: filter 0.2s ease;
  }
  .clock-time {
    min-width: 2.7em;
    color: #573826;
    font-size: clamp(15px, 2.2vh, 19px);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.03em;
    text-align: center;
    transition: color 0.2s ease;
  }
  .clock-widget.ringing {
    border-color: rgba(232, 79, 64, 0.42);
    box-shadow: 0 0 0 3px rgba(239, 91, 76, 0.12), 0 2px 8px rgba(150, 90, 40, 0.08);
  }
  .clock-widget.ringing .clock-icon {
    animation: clockSway 0.48s ease-in-out infinite;
  }
  .clock-widget.ringing .clock-svg {
    filter: drop-shadow(0 0 7px rgba(239, 91, 76, 0.42));
  }
  .clock-widget.ringing .clock-time {
    color: #e2473a;
    transition: none;
    animation: timeAlarm 0.9s ease-in-out infinite;
  }
  .ring-wave {
    opacity: 0;
    transform-box: fill-box;
    transform-origin: center;
    transition: opacity 0.15s ease;
  }
  .clock-widget.ringing .ring-wave {
    opacity: 1;
    animation: ringWave 0.48s ease-in-out infinite;
  }
  .clock-widget.ringing .ring-wave.right { animation-delay: 0.24s; }
  .time-gain {
    position: absolute;
    left: calc(100% + 6px);
    top: 50%;
    z-index: 3;
    padding: 1px 7px;
    border-radius: 999px;
    background: rgba(255, 252, 245, 0.94);
    font-size: clamp(10px, 1.5vh, 12px);
    font-weight: 800;
    color: #5d9e3f;
    pointer-events: none;
    white-space: nowrap;
    transform: translateY(-50%);
    animation: timeGain 1s ease-out forwards;
  }
  .time-gain.loss { color: #e2473a; }

  .corgi-zone {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    justify-self: end;
    gap: 1px;
    max-width: 62vw;
  }
  .corgi-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    line-height: 0;
  }
  .live-stars {
    display: flex;
    gap: 1px;
    margin-bottom: 1px;
    font-size: clamp(15px, 2.2vh, 21px);
    line-height: 1;
    letter-spacing: 1px;
    filter: drop-shadow(0 2px 2px rgba(150, 90, 40, 0.1));
  }
  .live-stars i {
    font-style: normal;
    line-height: 1;
    color: #c9a77f;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
    transition: color 0.25s ease, text-shadow 0.25s ease, transform 0.25s ease;
  }
  .live-stars i::before { content: "☆"; }
  .live-stars i.on {
    color: #ffb640;
    text-shadow: 0 1px 0 #fff, 0 3px 9px rgba(255, 150, 40, 0.45);
    transform: scale(1.08);
  }
  .live-stars i.on::before { content: "★"; }
  .corgi-art { flex: 0 0 auto; line-height: 0; }
  .corgi-art .corgi-img {
    display: block;
    height: clamp(84px, 14vh, 142px);
    width: auto;
    filter: drop-shadow(0 10px 14px rgba(150, 90, 40, 0.16));
    animation: bob 3.4s ease-in-out infinite;
  }
  .corgi-zone.mood-happy .corgi-img { animation: happyBounce 0.72s cubic-bezier(0.25, 0.9, 0.35, 1.2); }
  .corgi-zone.mood-sad .corgi-img { animation: sadShake 0.6s ease; }

  .wish-bubble {
    position: relative;
    margin-bottom: clamp(7px, 1.6vh, 18px);
    min-width: clamp(128px, 16vw, 166px);
    padding: 9px 12px 10px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
    border-radius: 16px 16px 5px 16px;
    box-shadow: 0 2px 8px rgba(150, 90, 40, 0.08);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
  }
  .wish-bubble::after {
    content: "";
    position: absolute;
    right: -9px;
    bottom: 10px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-left: 10px solid rgba(255, 255, 255, 0.72);
  }
  .wish-bubble.danger {
    border-color: rgba(239, 91, 76, 0.5);
    box-shadow: 0 8px 22px rgba(239, 91, 76, 0.18);
  }
  .wish-line { display: flex; align-items: center; gap: 8px; }
  .wish-food {
    width: clamp(30px, 4.2vh, 40px);
    height: auto;
    flex: 0 0 auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 2px rgba(150, 90, 40, 0.18));
  }
  .wish-food.pop { animation: popEmoji 0.42s cubic-bezier(0.2, 1.3, 0.4, 1); }
  .wish-label { font-size: clamp(12px, 1.8vh, 15px); color: #8d6d55; white-space: nowrap; }
  .wish-label b { color: var(--accent-deep); font-size: 1.08em; }
  .wish-secs {
    margin-top: 2px;
    font-size: clamp(10px, 1.55vh, 12px);
    color: #a3866f;
    font-variant-numeric: tabular-nums;
  }
  .wish-secs b { color: #c67a34; font-size: 1.1em; }
  .wish-track {
    height: 7px;
    margin-top: 7px;
    border-radius: 99px;
    background: #f4e0c8;
    overflow: hidden;
  }
  .wish-fill {
    display: block;
    height: 100%;
    width: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, #ffc24f, #ff8a3c);
    transition: width 0.1s linear, background 0.3s ease;
  }
  .wish-bubble.danger .wish-fill { background: linear-gradient(90deg, #ff8b70, #ef5b4c); }
  .wish-message { text-align: center; padding: 1px 1px 2px; }
  .wish-msg-title { font-size: clamp(12px, 1.9vh, 16px); font-weight: 800; color: #d9782c; }
  .wish-msg-sub { margin-top: 2px; font-size: clamp(9px, 1.45vh, 12px); color: #90715a; }

  .heart {
    position: absolute;
    bottom: 8px;
    z-index: 4;
    font-size: 15px;
    pointer-events: none;
    animation: heartUp 1.15s ease-out forwards;
  }

  .board-area {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1px 0;
  }
  .board {
    position: relative;
    border-radius: clamp(16px, 3vh, 28px);
    background-color: rgba(255, 250, 241, 0.82);
    background-image:
      linear-gradient(90deg, rgba(224, 142, 69, 0.055) 1px, transparent 1px),
      linear-gradient(rgba(224, 142, 69, 0.055) 1px, transparent 1px);
    background-size: clamp(18px, 4vh, 34px) clamp(18px, 4vh, 34px);
    box-shadow:
      0 22px 50px rgba(150, 90, 40, 0.15),
      inset 0 0 0 1.5px rgba(200, 140, 80, 0.18);
    touch-action: manipulation;
  }
  .path-layer {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    overflow: visible;
  }
  .path-line {
    fill: none;
    stroke: var(--accent);
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 1px 2px rgba(200, 120, 50, 0.28));
    stroke-dasharray: 4000;
    stroke-dashoffset: 4000;
    animation: pathDraw 0.17s ease-out forwards, pathFade 0.24s ease 0.36s forwards;
  }

  .tile-layer {
    position: absolute;
    inset: 0;
    z-index: 1;
  }
  .tile { position: absolute; z-index: 1; will-change: transform; }
  .tile-inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12%;
    background: url("assets/cards/card-cream.webp") center / 100% 100% no-repeat;
    border: 0;
    box-shadow: 0 4px 9px rgba(150, 90, 40, 0.14);
    cursor: pointer;
    transition: transform 0.14s ease, box-shadow 0.14s ease;
    animation: tileIn 0.35s backwards;
  }
  @media (hover: hover) {
    .tile:hover .tile-inner:not(.selected):not(.invalid) {
      transform: translateY(-2px);
      box-shadow: 0 8px 14px rgba(150, 90, 40, 0.2);
    }
  }
  .tile-inner .food {
    width: 72%;
    height: 72%;
    object-fit: contain;
    filter: drop-shadow(0 2px 2px rgba(150, 90, 40, 0.18));
    pointer-events: none;
    user-select: none;
  }
  .tile-inner.selected {
    transform: none;
    box-shadow:
      0 0 0 3px #ffb05c,
      0 0 0 7px rgba(255, 176, 92, 0.22),
      0 8px 14px rgba(150, 90, 40, 0.16);
  }
  .tile-inner.hint {
    background: linear-gradient(160deg, #fff7cf, #ffd36e);
    border-color: #ff9f1c;
    box-shadow:
      0 0 0 3px #ffb648,
      0 0 0 8px rgba(255, 182, 72, 0.28),
      0 0 24px rgba(255, 170, 50, 0.75),
      0 8px 16px rgba(150, 90, 40, 0.18);
    animation: hintPulse 0.8s ease-in-out infinite;
  }
  .tile-inner.hint .food {
    filter: drop-shadow(0 0 6px rgba(255, 190, 60, 0.9)) drop-shadow(0 2px 2px rgba(150, 90, 40, 0.16));
  }
  .tile-inner.invalid {
    transform: none;
    transition: none;
    background: linear-gradient(160deg, #ffe9e4, #ffb9ad);
    border-color: #e84f40;
    box-shadow:
      0 0 0 3px #e84f40,
      0 0 0 7px rgba(232, 79, 64, 0.24),
      0 8px 14px rgba(180, 60, 40, 0.16);
    animation: invalidFlash 0.55s ease;
  }
  .tile-inner.matched {
    transform: scale(1.38) rotate(9deg);
    opacity: 0;
    transition: transform 0.32s ease, opacity 0.32s ease;
  }

  .float-score {
    position: absolute;
    z-index: 6;
    transform: translate(-50%, -50%);
    font-size: clamp(14px, 2.2vh, 19px);
    font-weight: 800;
    color: var(--accent);
    text-shadow: 0 2px 0 #fff, 0 5px 12px rgba(255, 140, 50, 0.4);
    pointer-events: none;
    animation: floatUp 0.95s ease-out forwards;
  }
  .float-score.big { font-size: clamp(18px, 2.9vh, 25px); color: #f0742a; }
  .spark {
    position: absolute;
    z-index: 6;
    font-size: 13px;
    pointer-events: none;
    animation: sparkOut 0.7s ease-out forwards;
  }

  .toast {
    position: absolute;
    left: 50%;
    top: 8px;
    z-index: 20;
    transform: translate(-50%, -8px);
    padding: 7px 15px;
    border-radius: 999px;
    background: rgba(74, 50, 38, 0.9);
    color: #fff8ee;
    font-size: clamp(11px, 1.6vh, 13px);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    max-width: 92vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .toast.show { opacity: 1; transform: translate(-50%, 0); }

  .controls {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(6px, 1.2vw, 12px);
    padding-top: 1px;
  }
  .tool-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: clamp(36px, 5.4vh, 44px);
    padding: clamp(6px, 1.1vh, 10px) clamp(11px, 2vw, 18px);
    border: 1.5px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 252, 245, 0.84);
    color: #6a4a34;
    font-size: clamp(11px, 1.7vh, 14px);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(150, 90, 40, 0.1);
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease, opacity 0.2s ease;
  }
  .tool-btn:hover { transform: translateY(-1px); box-shadow: 0 7px 16px rgba(150, 90, 40, 0.14); }
  .tool-btn:active { transform: translateY(1px) scale(0.98); }
  .tool-btn.empty { opacity: 0.5; }
  .tool-btn.attention {
    border-color: rgba(240, 138, 60, 0.65);
    background: #fff1dc;
    color: #9a4d16;
    box-shadow: 0 0 0 3px rgba(240, 138, 60, 0.16), 0 4px 12px rgba(150, 90, 40, 0.12);
    animation: ctaPulse 1s ease-in-out infinite;
  }
  .tool-btn em {
    font-style: normal;
    min-width: 18px;
    padding: 1px 6px;
    border-radius: 99px;
    background: #ffe3bf;
    color: #c06a22;
    font-size: 0.86em;
    text-align: center;
  }
  .btn-icon {
    width: 1.55em;
    height: 1.55em;
    object-fit: contain;
    flex: 0 0 auto;
    filter: drop-shadow(0 2px 2px rgba(150, 90, 40, 0.15));
  }
  .primary-btn .btn-icon,
  .ghost-btn .btn-icon { width: 1.35em; height: 1.35em; }
  .icon-only { width: clamp(36px, 5.4vh, 44px); padding: 0; }

  .overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(92, 55, 28, 0.34);
    -webkit-backdrop-filter: blur(7px);
    backdrop-filter: blur(7px);
  }
  .overlay.show { display: flex; animation: fadeIn 0.22s ease; }
  .dialog {
    position: relative;
    z-index: 2;
    width: min(450px, 100%);
    max-height: min(92dvh, 720px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: clamp(17px, 3.2vh, 28px);
    text-align: center;
    background: linear-gradient(180deg, #fffdf8, #fff3e2);
    border: 1.5px solid rgba(200, 140, 80, 0.25);
    border-radius: clamp(20px, 3.4vh, 28px);
    box-shadow: 0 30px 80px rgba(80, 45, 20, 0.32);
    animation: dialogIn 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.15);
  }
  .dialog h2 {
    margin: 0 0 4px;
    font-size: clamp(21px, 3.8vh, 30px);
    letter-spacing: 0.02em;
    color: #573826;
  }
  .dialog .sub {
    margin: 2px 0 8px;
    font-size: clamp(11px, 1.8vh, 14px);
    line-height: 1.55;
    color: #9a7b64;
  }
  .dialog b { color: #c46a24; }
  .brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: clamp(25px, 4.8vh, 36px);
    font-weight: 900;
    letter-spacing: 0.06em;
    color: #573826;
    text-shadow: 0 2px 0 rgba(255, 255, 255, 0.7);
  }
  .brand span { font-size: 0.8em; transform: rotate(-12deg); }
  .tagline {
    margin: 4px 0 0;
    font-size: clamp(11px, 1.8vh, 13.5px);
    color: #9a7b64;
  }
  .start-hero {
    position: relative;
    height: clamp(176px, 26vh, 232px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    margin: 2px 0 2px;
  }
  .dialog-corgi { display: flex; justify-content: center; line-height: 0; }
  .dialog-corgi .corgi-img { height: clamp(96px, 16vh, 138px); width: auto; filter: drop-shadow(0 10px 16px rgba(150, 90, 40, 0.16)); }
  .dialog-corgi.mood-happy .corgi-img { animation: happyBounce 0.72s cubic-bezier(0.25, 0.9, 0.35, 1.2); }
  .dialog-corgi.mood-sad .corgi-img { animation: sadShake 0.6s ease; }
  .start-hero .dialog-corgi .corgi-img { height: clamp(158px, 23vh, 208px); }
  .start-thought {
    position: absolute;
    left: 50%;
    top: 6%;
    transform: translateX(-105%) rotate(-3deg);
    padding: 6px 10px;
    white-space: nowrap;
    font-size: clamp(10px, 1.6vh, 12px);
    color: #9a7b64;
    background: #fffdf8;
    border: 1.5px solid rgba(190, 120, 55, 0.2);
    border-radius: 12px 12px 4px 12px;
    box-shadow: 0 6px 14px rgba(150, 90, 40, 0.1);
  }
  .start-thought::after {
    content: "";
    position: absolute;
    right: -8px;
    bottom: 8px;
    border-top: 7px solid transparent;
    border-left: 9px solid #fffdf8;
  }
  .float-food {
    position: absolute;
    width: clamp(24px, 3.6vh, 34px);
    height: auto;
    opacity: 0.9;
    filter: drop-shadow(0 4px 6px rgba(150, 90, 40, 0.15));
    animation: floaty 3.4s ease-in-out infinite;
  }
  .float-food.f1 { left: 9%; top: 34%; animation-delay: -0.4s; }
  .float-food.f2 { right: 7%; top: 25%; animation-delay: -1.4s; }
  .float-food.f3 { right: 16%; bottom: 13%; width: clamp(20px, 3vh, 28px); animation-delay: -2.2s; }

  .rules {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin: 12px 0 4px;
    padding: 0;
    text-align: left;
  }
  .rules li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.58);
    border: 1px solid rgba(200, 140, 80, 0.14);
    font-size: clamp(11px, 1.75vh, 13px);
    line-height: 1.55;
    color: #7b5c45;
  }
  .rules li > span { flex: 0 0 auto; font-size: 1.1em; }
  .rules .rule-food { width: 22px; height: 22px; object-fit: contain; flex: 0 0 auto; }
  .rules.simple { margin: 6px 0 0; gap: 1px; }
  .rules.simple li {
    display: block;
    padding: 0 2px;
    background: transparent;
    border: 0;
    border-radius: 0;
    font-size: clamp(10px, 1.6vh, 12px);
    line-height: 1.45;
    color: #90715a;
  }

  .select-hero {
    position: relative;
    height: clamp(74px, 12vh, 98px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    margin: 2px 0 2px;
  }
  .select-hero .dialog-corgi .corgi-img { height: clamp(74px, 11.5vh, 96px); }
  .select-thought {
    position: absolute;
    right: calc(50% + clamp(38px, 5.8vh, 48px));
    top: 0;
    transform: rotate(-3deg);
    padding: 5px 9px;
    white-space: nowrap;
    font-size: clamp(10px, 1.55vh, 12px);
    color: #9a7b64;
    background: #fffdf8;
    border: 1.5px solid rgba(190, 120, 55, 0.2);
    border-radius: 12px 12px 4px 12px;
    box-shadow: 0 6px 14px rgba(150, 90, 40, 0.1);
  }
  .select-thought::after {
    content: "";
    position: absolute;
    right: -8px;
    bottom: 8px;
    border-top: 7px solid transparent;
    border-left: 9px solid #fffdf8;
  }
  .page-tabs {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 4px 0 6px;
  }
  .page-tab {
    appearance: none;
    padding: 3px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.6);
    color: #8a6a53;
    font-family: inherit;
    font-size: clamp(10px, 1.5vh, 12px);
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  }
  .page-tab.active {
    background: #ffe9c9;
    border-color: #ffb05c;
    color: #b56b22;
    font-weight: 800;
  }
  .page-tab.locked { opacity: 0.5; cursor: pointer; }
  .page-tab.locked.active { opacity: 0.85; }
  .page-tab:hover { border-color: #ffb05c; color: #b56b22; }
  .page-lock { font-size: 0.9em; }
  .page-progress {
    margin: 0 0 2px;
    font-size: clamp(10px, 1.6vh, 12px);
    color: #9a7b64;
  }
  .gate-hint {
    max-width: 300px;
    margin: 2px auto 0;
    font-size: clamp(10px, 1.5vh, 12px);
    line-height: 1.5;
    color: #c46a24;
  }
  .level-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    margin: 8px 0 4px;
  }
  .level-btn {
    appearance: none;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    min-height: clamp(58px, 8.2vh, 68px);
    padding: 5px 4px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.66);
    color: #6a4a34;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(150, 90, 40, 0.08);
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  }
  .level-btn:hover:not(.locked) {
    transform: translateY(-2px);
    box-shadow: 0 7px 14px rgba(150, 90, 40, 0.14);
  }
  .level-btn:active:not(.locked) { transform: translateY(1px) scale(0.99); }
  .level-btn.done { background: linear-gradient(180deg, #fffdf8, #fff1dc); }
  .level-btn.next {
    border-color: #ffb05c;
    box-shadow: 0 0 0 3px rgba(255, 176, 92, 0.2), 0 4px 10px rgba(150, 90, 40, 0.1);
  }
  .level-btn.next::after {
    content: "NEW";
    position: absolute;
    top: 4px;
    right: 5px;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: #e2741f;
  }
  .level-btn.locked {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(245, 235, 222, 0.6);
    box-shadow: none;
  }
  .level-no { font-size: clamp(15px, 2.1vh, 18px); font-weight: 800; line-height: 1; color: #573826; }
  .level-food {
    width: clamp(22px, 3.2vh, 28px);
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 2px rgba(150, 90, 40, 0.15));
  }
  .level-lock { font-size: clamp(17px, 2.6vh, 21px); line-height: 1.2; opacity: 0.8; }
  .level-stars {
    display: flex;
    gap: 1px;
    font-size: 9px;
    line-height: 1;
    color: #e6d2ba;
    letter-spacing: 0.5px;
  }
  .level-stars i { font-style: normal; }
  .level-stars i.on { color: #ffb640; text-shadow: 0 1px 0 #fff, 0 2px 6px rgba(255, 150, 40, 0.35); }

  .reward-box {
    position: relative;
    margin: 10px auto 2px;
    width: min(240px, 100%);
    padding: 8px 12px 9px;
    border-radius: 16px;
    background: linear-gradient(180deg, #fff8e8, #ffe9c9);
    border: 1.5px solid rgba(240, 166, 90, 0.55);
    box-shadow: 0 8px 18px rgba(240, 150, 50, 0.18);
    overflow: hidden;
  }
  .reward-box::after {
    content: "";
    position: absolute;
    inset: -40% -60%;
    background: linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, 0.8) 50%, transparent 58%);
    transform: translateX(-70%);
    animation: rewardShine 1.5s ease 0.15s both;
    pointer-events: none;
  }
  .reward-head { font-size: 10px; font-weight: 800; letter-spacing: 0.14em; color: #b87935; }
  .reward-img {
    display: block;
    width: clamp(64px, 10vh, 82px);
    height: auto;
    margin: 1px auto;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(150, 90, 40, 0.2));
    animation: rewardPop 0.9s cubic-bezier(0.2, 1.4, 0.4, 1) both;
  }
  .reward-name { font-size: clamp(13px, 2vh, 16px); font-weight: 800; color: #c46a24; }
  @keyframes rewardPop {
    0% { opacity: 0; transform: scale(0.2) rotate(-25deg); }
    55% { opacity: 1; transform: scale(1.15) rotate(6deg); }
    100% { opacity: 1; transform: scale(1) rotate(0); }
  }
  @keyframes rewardShine {
    0% { transform: translateX(-70%); }
    100% { transform: translateX(70%); }
  }

  .dialog-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
  }
  .primary-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 184px;
    padding: clamp(11px, 2vh, 14px) 30px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(180deg, #ffa64f, #f07b2c);
    color: #fff;
    font-size: clamp(15px, 2.3vh, 18px);
    font-weight: 800;
    letter-spacing: 0.03em;
    box-shadow: 0 9px 22px rgba(240, 123, 44, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.42);
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
  }
  .primary-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(240, 123, 44, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.42); }
  .primary-btn:active { transform: translateY(1px) scale(0.99); }
  .ghost-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 184px;
    padding: 10px 22px;
    border: 1.5px solid rgba(190, 120, 55, 0.3);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.5);
    color: #8a6a53;
    font-size: clamp(12px, 1.8vh, 14px);
    font-weight: 700;
    cursor: pointer;
    transition: background 0.12s ease, transform 0.12s ease;
  }
  .ghost-btn:hover { background: rgba(255, 255, 255, 0.85); transform: translateY(-1px); }
  .best-line { margin-top: 10px; font-size: clamp(10px, 1.5vh, 12px); color: #a3866f; }

  .stars-big {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 2px 0 2px;
    font-size: clamp(40px, 8vh, 58px);
    line-height: 1;
    color: #eadac6;
  }
  .stars-big i {
    font-style: normal;
    display: inline-block;
    transform: scale(0.7);
    opacity: 0.32;
    transition: transform 0.25s ease, opacity 0.25s ease, color 0.25s ease;
  }
  .stars-big i.on {
    color: #ffb43c;
    opacity: 1;
    transform: scale(1);
    text-shadow: 0 3px 0 rgba(240, 138, 44, 0.25), 0 8px 20px rgba(255, 160, 40, 0.42);
    animation: starPop 0.55s backwards cubic-bezier(0.2, 1.4, 0.4, 1);
  }
  .stars-big i.on:nth-child(2) { animation-delay: 0.12s; }
  .stars-big i.on:nth-child(3) { animation-delay: 0.24s; }
  .result-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 12px 0 4px;
  }
  .result-grid > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    padding: 8px 5px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid rgba(200, 140, 80, 0.14);
  }
  .result-grid span { font-size: clamp(9px, 1.4vh, 11px); color: #a3866f; }
  .result-grid b {
    font-size: clamp(14px, 2.1vh, 18px);
    color: #573826;
    font-variant-numeric: tabular-nums;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .confetti {
    position: fixed;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    overflow: hidden;
  }
  .confetti i {
    position: absolute;
    top: -32px;
    animation-name: confettiFall;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
  }

  @keyframes bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
  }
  @keyframes wag {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(7deg); }
  }
  @keyframes happyBounce {
    0% { transform: translateY(0) scale(1); }
    30% { transform: translateY(-9px) scale(1.06); }
    58% { transform: translateY(0) scale(0.98); }
    78% { transform: translateY(-4px) scale(1.02); }
    100% { transform: translateY(0) scale(1); }
  }
  @keyframes sadShake {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    20% { transform: translateX(-4px) rotate(-2deg); }
    40% { transform: translateX(4px) rotate(2deg); }
    60% { transform: translateX(-3px) rotate(-1deg); }
    80% { transform: translateX(2px) rotate(1deg); }
  }
  @keyframes tearFall {
    0% { opacity: 0; transform: translateY(-2px); }
    30% { opacity: 1; }
    100% { opacity: 0; transform: translateY(8px); }
  }
  @keyframes scorePop {
    0% { transform: scale(1); }
    35% { transform: scale(1.12); }
    100% { transform: scale(1); }
  }
  @keyframes popEmoji {
    0% { transform: scale(0.5) rotate(-12deg); }
    70% { transform: scale(1.18) rotate(5deg); }
    100% { transform: scale(1) rotate(0); }
  }
  @keyframes popBubble {
    0% { transform: scale(1); }
    40% { transform: scale(1.06); }
    100% { transform: scale(1); }
  }
  .wish-bubble.pulse { animation: popBubble 0.42s ease; }
  @keyframes timeGain {
    0% { opacity: 0; transform: translateY(-30%) scale(0.9); }
    25% { opacity: 1; transform: translateY(-50%) scale(1); }
    100% { opacity: 0; transform: translateY(-145%) scale(1); }
  }
  @keyframes ctaPulse {
    0%, 100% { transform: translateY(0); box-shadow: 0 0 0 3px rgba(240, 138, 60, 0.16), 0 4px 12px rgba(150, 90, 40, 0.12); }
    50% { transform: translateY(-2px); box-shadow: 0 0 0 6px rgba(240, 138, 60, 0.08), 0 7px 16px rgba(150, 90, 40, 0.16); }
  }
  @keyframes clockSway {
    0%, 100% { transform: rotate(-7deg); }
    50% { transform: rotate(7deg); }
  }
  @keyframes ringWave {
    0%, 100% { opacity: 0.15; transform: scale(0.85); }
    50% { opacity: 1; transform: scale(1.12); }
  }
  @keyframes timeAlarm {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.07); }
  }
  @keyframes tileIn {
    from { transform: scale(0.55) rotate(-6deg); opacity: 0; }
    to { transform: scale(1) rotate(0); opacity: 1; }
  }
  @keyframes hintPulse {
    0%, 100% {
      transform: scale(1.04);
      box-shadow:
        0 0 0 3px #ffb648,
        0 0 0 7px rgba(255, 182, 72, 0.28),
        0 0 18px rgba(255, 170, 50, 0.7),
        0 6px 14px rgba(150, 90, 40, 0.16);
    }
    50% {
      transform: scale(1.12);
      box-shadow:
        0 0 0 4px #ff9f1c,
        0 0 0 11px rgba(255, 182, 72, 0.22),
        0 0 30px rgba(255, 170, 50, 0.9),
        0 10px 22px rgba(150, 90, 40, 0.2);
    }
  }
  @keyframes invalidFlash {
    0% { box-shadow: 0 0 0 3px #e84f40, 0 0 0 7px rgba(232, 79, 64, 0.34), 0 8px 14px rgba(180, 60, 40, 0.16); }
    50% { box-shadow: 0 0 0 3px rgba(232, 79, 64, 0.38), 0 0 0 9px rgba(232, 79, 64, 0.1), 0 8px 14px rgba(180, 60, 40, 0.1); }
    100% { box-shadow: 0 0 0 3px #e84f40, 0 0 0 7px rgba(232, 79, 64, 0.24), 0 8px 14px rgba(180, 60, 40, 0.16); }
  }
  @keyframes pathDraw {
    to { stroke-dashoffset: 0; }
  }
  @keyframes pathFade {
    to { opacity: 0; }
  }
  @keyframes floatUp {
    0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
    22% { opacity: 1; transform: translate(-50%, -60%) scale(1.06); }
    100% { opacity: 0; transform: translate(-50%, -165%) scale(1); }
  }
  @keyframes sparkOut {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
    25% { opacity: 1; }
    100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1); }
  }
  @keyframes heartUp {
    0% { opacity: 0; transform: translateY(6px) scale(0.6); }
    20% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-58px) scale(1.1) rotate(var(--rot, 12deg)); }
  }
  @keyframes floaty {
    0%, 100% { transform: translateY(0) rotate(-4deg); }
    50% { transform: translateY(-9px) rotate(4deg); }
  }
  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }
  @keyframes dialogIn {
    from { opacity: 0; transform: translateY(14px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }
  @keyframes starPop {
    0% { transform: scale(0) rotate(-30deg); }
    70% { transform: scale(1.18) rotate(5deg); }
    100% { transform: scale(1) rotate(0); }
  }
  @keyframes confettiFall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(110vh) rotate(540deg); opacity: 0.9; }
  }

  @media (max-width: 680px) {
    .hud {
      grid-template-columns: auto auto minmax(0, 1fr);
      grid-template-rows: auto auto;
      align-items: center;
      column-gap: clamp(6px, 1.2vw, 10px);
      row-gap: 2px;
    }
    .hud-left { grid-column: 1; grid-row: 1; justify-self: start; }
    .clock-slot { grid-column: 2; grid-row: 1; justify-self: start; }
    .corgi-zone { grid-column: 1 / -1; grid-row: 2; justify-self: end; }
  }
  @media (max-width: 390px) {
    .corgi-art .corgi-img { height: 78px; }
    .wish-bubble { min-width: 104px; padding: 7px 9px 8px; margin-bottom: 8px; }
    .wish-food { width: 26px; }
    .wish-label { font-size: 11px; }
    .wish-track { height: 6px; margin-top: 5px; }
    .score-label { font-size: 10px; }
    .tool-btn { gap: 4px; padding: 6px 10px; }
    .tool-btn em { min-width: 15px; padding: 1px 4px; }
    .corgi-zone { max-width: 66vw; }
    .live-stars { font-size: 14px; }
    .level-grid { gap: 5px; }
    .level-btn { min-height: 58px; padding: 4px 2px; }
    .level-no { font-size: 14px; }
    .level-food { width: 20px; }
    .level-stars { font-size: 8px; }
    .page-tab { padding: 2px 8px; }
    .select-hero { height: 84px; }
    .select-hero .dialog-corgi .corgi-img { height: 80px; }
    .rules.simple li { font-size: 10px; }
  }
  @media (max-width: 344px) {
    .wish-word { display: none; }
    .score-label { display: none; }
    .score-chip { padding: 0 10px; }
    .level-chip { padding: 0 9px; }
  }
  @media (max-height: 580px) {
    .hud-pill { height: 32px; padding: 0 9px; }
    .level-chip { font-size: 11px; }
    .score-val { font-size: 16px; }
    .clock-icon { width: 19px; }
    .clock-time { font-size: 13px; min-width: 2.5em; }
    .live-stars { font-size: 13px; }
    .corgi-art .corgi-img { height: 68px; }
    .wish-bubble { margin-bottom: 7px; padding: 6px 9px 7px; min-width: 108px; }
    .wish-food { width: 24px; }
    .wish-track { height: 6px; margin-top: 5px; }
    .tool-btn { min-height: 33px; padding: 5px 11px; }
    .icon-only { width: 33px; }
    .dialog-corgi .corgi-img { height: 84px; }
    .start-hero { height: 150px; }
    .start-hero .dialog-corgi .corgi-img { height: 136px; }
    .select-hero { height: 84px; }
    .select-hero .dialog-corgi .corgi-img { height: 78px; }
    .level-btn { min-height: 60px; }
    .level-grid { gap: 6px; }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
