:root {
    --cream:        #FBF4E8;
    --cream-deep:  #F5E9D3;
    --milk:        #FFFDF8;
    --rose:        #F4B6C2;
    --rose-deep:   #E48BA0;
    --mint:        #B8DDC8;
    --mint-deep:   #6FB89A;
    --cocoa:       #4A3528;
    --cocoa-soft:  #6B4F3E;
    --sun:         #F5C76A;
    --lavender:    #C9B8E0;

    --scene-morning:   linear-gradient(180deg, #FFE8D6 0%, #F5C76A 50%, #E8B894 100%);
    --scene-afternoon: linear-gradient(180deg, #F5E0D8 0%, #F4B6C2 50%, #E8C4A8 100%);
    --scene-evening:   linear-gradient(180deg, #C9B8E0 0%, #E48BA0 50%, #6B4F3E 100%);

    --shadow-soft:   0 4px 16px rgba(74, 53, 40, 0.08);
    --shadow-card:   0 8px 28px rgba(74, 53, 40, 0.14);
    --shadow-tile:   0 3px 8px rgba(74, 53, 40, 0.18);

    --safe-top:    env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* Opt out of Android WebView's automatic darkening - we ship our own
     Night theme below, so the OS must not repaint the cosy one. */
  html { color-scheme: light; }
  html body.night { color-scheme: dark; }

  /* -- NIGHT MODE (toggle in Settings) -- */
  /* Candlelit cafe after hours: warm roasted browns, amber glow. */
  body.night {
    --cream:       #241B13;
    --cream-deep:  #3E3023;
    --milk:        #30251A;
    --cocoa:       #FCF2E2;
    --cocoa-soft:  #DCC5A6;
    --rose:        #F0B6AC;
    --rose-deep:   #F2AC9E;
    --mint:        #A6CBA6;
    --mint-deep:   #B2DDB0;
    --sun:         #F8CF7C;
    --lavender:    #DCC0A8;
    --scene-morning:   linear-gradient(180deg, #4E3922 0%, #61452A 50%, #34261A 100%);
    --scene-afternoon: linear-gradient(180deg, #422F20 0%, #5A3F27 50%, #2F2318 100%);
    --scene-evening:   linear-gradient(180deg, #35251A 0%, #4C3423 50%, #251A12 100%);
    --shadow-soft:   0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-card:   0 8px 28px rgba(0, 0, 0, 0.45);
    --shadow-tile:   0 3px 8px rgba(0, 0, 0, 0.5);
    --board-tray:    rgba(62, 48, 35, 0.85);
  }

  * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

  html, body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body {
    font-family: 'Nunito', system-ui, sans-serif;
    color: var(--cocoa);
    background: var(--cream);
    -webkit-user-select: none;
    user-select: none;
    background-image:
      radial-gradient(circle at 20% 30%, rgba(244, 182, 194, 0.10) 0%, transparent 45%),
      radial-gradient(circle at 80% 70%, rgba(184, 221, 200, 0.10) 0%, transparent 45%);
    touch-action: manipulation;
  }

  .app {
    height: 100vh;
    height: 100dvh;
    max-width: 540px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    padding: calc(var(--safe-top) + 8px) 12px calc(var(--safe-bottom) + 8px);
    position: relative;
  }

  /* TOP BAR */
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 4px 10px;
    flex-shrink: 0;
  }
  .brand {
    font-family: 'Fraunces', serif;
    font-weight: 900;
    font-size: 22px;
    line-height: 1;
    letter-spacing: -0.02em;
  }
  .brand em { font-style: italic; font-weight: 400; color: var(--rose-deep); }
  .topbar-stats { display: flex; gap: 6px; align-items: center; }
  /* Coins are the main currency - make them unmissable. */
  .stat-pill.coins {
    background: linear-gradient(135deg, #FFF3D0, #F7DFA0);
    border-color: var(--sun);
    font-size: 17px;
    padding: 7px 15px;
    box-shadow: 0 3px 10px rgba(245, 199, 106, .45);
  }
  body.night .stat-pill.coins {
    background: linear-gradient(135deg, #4A3F2A, #5C4B2E);
    border-color: var(--sun);
    color: var(--sun);
  }
  .stat-pill.coins #coinCount { font-size: 18px; font-weight: 900; letter-spacing: -.01em; }
  .stat-pill {
    background: var(--milk);
    border: 2px solid var(--cream-deep);
    padding: 5px 11px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: var(--shadow-soft);
  }

  /* GUEST HUD */
  .guest-hud {
    background: var(--milk);
    border: 2px dashed var(--cream-deep);
    border-radius: 18px;
    padding: 12px 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-soft);
    flex-shrink: 0;
  }
  .guest-row { display: flex; align-items: center; gap: 12px; }
  .guest-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--cream-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    flex-shrink: 0;
    border: 3px solid var(--rose);
    transition: border-color 0.4s ease;
    position: relative;
  }
  .guest-avatar.happy { animation: bounce 0.6s ease; border-color: var(--mint-deep); }
  .guest-avatar.sad   { animation: shake 0.4s ease; }
  .guest-avatar.flash { animation: avatarFlash 0.6s ease; }
  @keyframes avatarFlash {
    0%, 100% { box-shadow: 0 0 0 0 rgba(228, 139, 160, 0); }
    50% { box-shadow: 0 0 0 8px rgba(228, 139, 160, 0.5); }
  }
  .guest-hat {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 20px;
    pointer-events: none;
  }
  .guest-accessory {
    position: absolute;
    bottom: -6px;
    right: -6px;
    font-size: 16px;
    pointer-events: none;
  }
  @keyframes bounce {
    0%, 100% { transform: translateY(0); }
    30%      { transform: translateY(-8px) scale(1.1); }
    60%      { transform: translateY(0) scale(1); }
  }
  @keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-4px) rotate(-3deg); }
    75%      { transform: translateX(4px) rotate(3deg); }
  }
  .guest-info { flex: 1; min-width: 0; }
  .guest-name { font-family: 'Fraunces', serif; font-weight: 700; font-size: 15px; line-height: 1.1; }
  .guest-craving { font-size: 12px; color: var(--cocoa-soft); margin-top: 2px; }
  .guest-craving strong { color: var(--cocoa); }
  .craving-bar {
    margin-top: 6px;
    height: 7px;
    background: var(--cream-deep);
    border-radius: 100px;
    overflow: hidden;
  }
  .craving-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--rose), var(--sun));
    border-radius: 100px;
    width: 0%;
    transition: width 0.4s ease;
  }
  .craving-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--cream);
    border: 2px dashed var(--rose);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    animation: pulse 2.5s ease-in-out infinite;
  }
  .craving-icon svg { width: 70%; height: 70%; }
  @keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
  }
  .order-board {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--cream-deep);
    align-items: center;
    font-size: 11px;
    color: var(--cocoa-soft);
  }
  .order-label { font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
  .order-queue { display: flex; gap: 6px; flex: 1; }
  .order-chip {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--cream);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    border: 2px solid var(--cream-deep);
  }
  .streak-badge {
    background: var(--sun);
    color: var(--cocoa);
    padding: 3px 9px;
    border-radius: 100px;
    font-weight: 800;
    font-size: 11px;
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  .streak-badge.active { opacity: 1; }

  /* BOARD */
  .board-wrap {
    flex: 1;
    position: relative;
    border-radius: 22px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .cafe-scene {
    position: absolute;
    inset: 0;
    background: var(--scene-afternoon);
    z-index: 0;
    transition: background 1.5s ease;
  }
  .cafe-scene.morning   { background: var(--scene-morning); }
  .cafe-scene.afternoon { background: var(--scene-afternoon); }
  .cafe-scene.evening   { background: var(--scene-evening); }
  .cafe-scene svg { width: 100%; height: 100%; display: block; }
  .sparkle-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
  .board {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 3px;
    padding: 10px;
    background: var(--board-tray, rgba(251, 244, 232, 0.85));
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 18px;
    width: min(96%, 96vw);
    max-width: 480px;
    aspect-ratio: 1;
    touch-action: none;
  }
  .tile {
    position: relative;
    background: var(--milk);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-tile);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    aspect-ratio: 1;
  }
  .tile:hover { transform: translateY(-1px); }
  .tile.selected {
    transform: scale(1.08);
    box-shadow: 0 0 0 3px var(--rose-deep), var(--shadow-tile);
    z-index: 3;
  }
  .tile.matching { animation: pop 0.4s ease forwards; }
  .tile.falling { animation: fall 0.35s ease; }
  .tile.shake { animation: tileShake 0.3s ease; }
  @keyframes tileShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
  }

  .combo-badge {
    position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    z-index: 6; display: flex; flex-direction: column; align-items: center; gap: 1px;
    padding: 4px 14px; border-radius: 100px;
    background: rgba(255, 253, 248, .94); border: 2px solid var(--sun);
    box-shadow: var(--shadow-card); opacity: 0; pointer-events: none;
    transition: opacity .2s ease;
  }
  .combo-badge.show { opacity: 1; }
  .combo-badge .combo-count { font-weight: 900; font-size: 18px; line-height: 1; color: var(--cocoa); }
  .combo-badge .combo-tier { font-weight: 800; font-size: 9px; letter-spacing: .06em; text-transform: uppercase; color: var(--rose-deep); }
  .combo-badge[data-tier="t3"] { border-color: var(--rose-deep); }
  .combo-badge[data-tier="t4"] { border-color: var(--lavender); }
  .combo-badge[data-tier="t5"] { border-color: var(--rose-deep); background: linear-gradient(135deg, var(--cream), var(--rose)); }
  .combo-badge[data-tier="t5"] .combo-tier { color: var(--cocoa); }
  .combo-badge.pop { animation: comboPop .3s ease; }
  @keyframes comboPop {
    0% { transform: translateX(-50%) scale(1); }
    40% { transform: translateX(-50%) scale(1.15); }
    100% { transform: translateX(-50%) scale(1); }
  }
  @keyframes pop {
    0%   { transform: scale(1); opacity: 1; }
    50%  { transform: scale(1.25) rotate(8deg); }
    100% { transform: scale(0); opacity: 0; }
  }
  @keyframes fall {
    0%   { transform: translateY(-30px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
  }
  .tile svg { width: 72%; height: 72%; pointer-events: none; }
  .tile * { pointer-events: none; }

  /* Subtle breathing on idle tile SVGs (not the tile itself, that would
     conflict with the pop animation when matching). */
  @keyframes breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
  }
  .tile:not(.matching):not(.selected) > svg {
    animation: breathe 4s ease-in-out infinite;
  }
  .tile:nth-child(3n) > svg { animation-delay: 0.5s; }
  .tile:nth-child(5n) > svg { animation-delay: 1.2s; }
  .tile:nth-child(7n) > svg { animation-delay: 1.9s; }

  /* Floating petals */
  .petal {
    position: absolute;
    font-size: 14px;
    pointer-events: none;
    opacity: 0;
    z-index: 4;
  }
  @keyframes petalDrift {
    0%   { transform: translate(0, 0) rotate(0deg); opacity: 0; }
    10%  { opacity: 0.7; }
    90%  { opacity: 0.7; }
    100% { transform: translate(var(--drift-x, 60px), 110%) rotate(360deg); opacity: 0; }
  }

  /* Rain on the window */
  .rain-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 2s ease;
  }
  .rain-layer.active { opacity: 1; }
  .raindrop {
    position: absolute;
    width: 1.5px;
    background: linear-gradient(180deg, transparent, rgba(200, 220, 240, 0.6));
    border-radius: 100px;
    animation: raindrop linear infinite;
  }
  @keyframes raindrop {
    0%   { transform: translateY(-20px); }
    100% { transform: translateY(120%); }
  }

  /* Walking cat */
  /* Floating "+N coin" feedback */
  .coin-float { position: fixed; z-index: 120; pointer-events: none; font-family: 'Fraunces', serif; font-weight: 900; font-size: 18px; color: #C9992F; text-shadow: 0 1px 3px rgba(255,255,255,.6); animation: coinFloat .9s ease-out forwards; }
  body.night .coin-float { color: var(--sun); text-shadow: 0 1px 4px rgba(0,0,0,.6); }
  @keyframes coinFloat { 0% { opacity: 0; transform: translateY(0) scale(.7); } 15% { opacity: 1; transform: translateY(-6px) scale(1.1); } 100% { opacity: 0; transform: translateY(-42px) scale(1); } }
  .stat-pill.coins.bump { animation: coinBump .35s ease; }
  @keyframes coinBump { 0%,100% { transform: scale(1); } 40% { transform: scale(1.18); } }
  /* Idle hint: gently pulse a valid pair */
  .tile.hint { animation: hintPulse 1s ease-in-out infinite; z-index: 5; }
  @keyframes hintPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.16); filter: brightness(1.15) drop-shadow(0 0 8px var(--sun)); } }
  /* Notification dot on nav buttons */
  .bb-btn { position: relative; }
  .nav-dot { position: absolute; top: 3px; right: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--rose-deep); border: 2px solid var(--milk); display: none; }
  .nav-dot.show { display: block; }

  /* GIFTS / DAILY REWARDS */
  .gift-section { background: var(--milk); border: 2px solid var(--cream-deep); border-radius: 16px; padding: 14px; margin-bottom: 14px; }
  .gift-section-title { font-family: 'Fraunces', serif; font-weight: 600; color: var(--cocoa); font-size: 16px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
  .streak-badge { font-family: 'Nunito', sans-serif; font-size: 11px; font-weight: 800; background: var(--rose-deep); color: #fff; padding: 3px 9px; border-radius: 100px; }
  .streak-badge:empty { display: none; }
  .daily-track { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 12px; }
  .daily-cell { position: relative; min-width: 0; aspect-ratio: 1; border-radius: 10px; background: var(--cream); border: 2px solid var(--cream-deep); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 2px; }
  .daily-cell .dc-day { font-size: 8px; font-weight: 800; color: var(--cocoa-soft); text-transform: uppercase; letter-spacing: 0.3px; }
  .daily-cell .dc-emoji { font-size: 16px; line-height: 1; }
  .daily-cell .dc-amt { font-size: 8px; font-weight: 800; color: var(--cocoa); }
  .daily-cell.claimed { opacity: 0.55; }
  .daily-cell.claimed::after { content: '✓'; position: absolute; top: 2px; right: 4px; font-size: 10px; font-weight: 900; color: var(--sage-deep, #6b9a5f); }
  .daily-cell.today { border-color: var(--rose-deep); background: #fff; box-shadow: 0 0 0 2px var(--rose-deep) inset; }
  .daily-cell.big { border-color: #d8a13a; background: #fff7e6; }
  .gift-claim-btn { width: 100%; background: var(--cocoa); color: var(--cream); border: none; font-family: 'Fraunces', serif; font-weight: 600; font-size: 15px; padding: 12px; border-radius: 14px; cursor: pointer; transition: all 0.2s ease; }
  .gift-claim-btn:active { transform: scale(0.98); }
  .gift-claim-btn:disabled { opacity: 0.5; cursor: default; }
  .gift-claim-btn.ready { background: var(--rose-deep); animation: giftPulse 1.6s ease-in-out infinite; }
  @keyframes giftPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(214,120,120,0.5); } 50% { box-shadow: 0 0 0 8px rgba(214,120,120,0); } }

  .booster-bar { display: flex; gap: 8px; justify-content: center; padding: 6px 0 2px; }
  .booster-btn { position: relative; flex: 1; max-width: 110px; background: var(--milk); border: 2px solid var(--cream-deep); border-radius: 14px; padding: 7px 4px 5px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 1px; transition: transform .1s; }
  .booster-btn:active { transform: scale(.95); }
  .booster-btn.empty { opacity: .6; }
  .booster-btn .bst-emoji { font-size: 22px; line-height: 1; }
  .booster-btn .bst-name { font-size: 10px; font-weight: 800; color: var(--cocoa-soft); }
  .booster-btn .bst-count { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; border-radius: 100px; background: var(--rose-deep); color: var(--cream); font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
  .booster-btn.empty .bst-count { background: var(--cocoa-soft); }
  .pshop-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--milk); border: 2px solid var(--cream-deep); border-radius: 14px; margin-bottom: 8px; }
  .pshop-emoji { font-size: 28px; }
  .pshop-body { flex: 1; min-width: 0; }
  .pshop-name { font-family: 'Fraunces', serif; font-weight: 700; font-size: 14px; color: var(--cocoa); }
  .pshop-desc { font-size: 11px; color: var(--cocoa-soft); margin-top: 1px; }
  .pshop-own { font-size: 11px; font-weight: 800; color: var(--rose-deep); margin-top: 2px; }
  .cat {
    position: absolute;
    bottom: 12%;
    left: 0;
    font-size: 28px;
    z-index: 3;
    pointer-events: none;
    opacity: 0;
    transform: translateX(-60px);
    will-change: transform;
  }
  @keyframes catWalkRight {
    0%   { transform: translateX(-60px) translateY(0); opacity: 0; }
    5%   { opacity: 1; }
    20%  { transform: translateX(20vw) translateY(0); }
    22%  { transform: translateX(22vw) translateY(-3px); }
    24%  { transform: translateX(24vw) translateY(0); }
    50%  { transform: translateX(50vw) translateY(0); }
    52%  { transform: translateX(52vw) translateY(-3px); }
    54%  { transform: translateX(54vw) translateY(0); }
    95%  { opacity: 1; }
    100% { transform: translateX(calc(100vw + 60px)) translateY(0); opacity: 0; }
  }
  @keyframes catWalkLeft {
    0%   { transform: translateX(calc(100vw + 60px)) scaleX(-1); opacity: 0; }
    5%   { opacity: 1; }
    50%  { transform: translateX(50vw) scaleX(-1) translateY(0); }
    52%  { transform: translateX(50vw) scaleX(-1) translateY(-3px); }
    54%  { transform: translateX(50vw) scaleX(-1) translateY(0); }
    95%  { opacity: 1; }
    100% { transform: translateX(-60px) scaleX(-1); opacity: 0; }
  }
  .cat.active-right { animation: catWalkRight 14s linear; }
  .cat.active-left  { animation: catWalkLeft 14s linear; }

  /* Special tiles: an emoji badge over the snack marks it as a power tile. */
  .tile.bomb::after, .tile.cross::after {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: 21px; z-index: 3; pointer-events: none; animation: specialPulse 1.1s ease-in-out infinite;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,.35));
  }
  .tile.bomb::after { content: '💣'; }
  .tile.cross::after { content: '✨'; }
  @keyframes specialPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.18); } }
  .tile.striped-h::before, .tile.striped-v::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(90deg, transparent 0, transparent 4px, rgba(255,255,255,0.55) 4px, rgba(255,255,255,0.55) 6px);
    border-radius: 10px;
    pointer-events: none;
  }
  .tile.striped-v::before {
    background: repeating-linear-gradient(0deg, transparent 0, transparent 4px, rgba(255,255,255,0.55) 4px, rgba(255,255,255,0.55) 6px);
  }
  .tile.rainbow {
    background: conic-gradient(from 0deg, #F4B6C2, #F5C76A, #B8DDC8, #C9B8E0, #F4B6C2);
  }

  /* Frosted tiles: a light seasonal hazard, matches normally by type but
     absorbs its first clear as a "thaw" instead of actually clearing. */
  .tile.frosted::after {
    content: '❄️';
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: 15px; z-index: 4; color: #fff; pointer-events: none;
    background: linear-gradient(160deg, rgba(180,220,255,.55), rgba(140,190,255,.32));
    border-radius: 10px;
    filter: drop-shadow(0 1px 2px rgba(20,60,110,.4));
  }
  .tile.thawing { animation: tileThaw .4s ease; }
  @keyframes tileThaw {
    0% { filter: brightness(1.5) saturate(0); }
    100% { filter: none; }
  }

  /* BOTTOM BAR */
  .bottombar {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    flex-shrink: 0;
  }
  .bb-btn {
    flex: 1;
    background: var(--milk);
    border: 2px solid var(--cream-deep);
    color: var(--cocoa);
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 11px;
    padding: 10px 6px;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    box-shadow: var(--shadow-soft);
  }
  .bb-btn:active { transform: scale(0.96); }
  .bb-btn.active { background: var(--cocoa); color: var(--cream); border-color: var(--cocoa); }
  .bb-btn.cant-afford { opacity: 0.45; }
  .bb-icon { font-size: 18px; line-height: 1; }

  /* TOAST */
  .toast {
    position: fixed;
    top: calc(var(--safe-top) + 16px);
    left: 50%;
    transform: translateX(-50%) translateY(-120px);
    background: var(--cocoa);
    color: var(--cream);
    padding: 12px 22px;
    border-radius: 100px;
    font-family: 'Fraunces', serif;
    font-weight: 700;
    font-size: 14px;
    box-shadow: var(--shadow-card);
    transition: transform 0.4s ease;
    z-index: 100;
    pointer-events: none;
    max-width: 88vw;
    text-align: center;
  }
  .toast.show { transform: translateX(-50%) translateY(0); }
  /* NB: prefixed to avoid colliding with game-system.css's .achievement
     (which is a square grid card and mangled the toast). */
  .toast.t-achievement { background: var(--sun); color: var(--cocoa); }
  .toast.t-combo { background: var(--rose-deep); color: var(--cream); }

  /* MODAL */
  .modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(74, 53, 40, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
  }
  .modal-backdrop.show { display: flex; }
  .modal {
    background: var(--cream);
    border-radius: 24px;
    padding: 24px 22px;
    max-width: 420px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    box-shadow: var(--shadow-card);
    border: 2px dashed var(--cream-deep);
  }
  .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
  }
  .modal-title { font-family: 'Fraunces', serif; font-size: 24px; font-weight: 900; }
  .modal-title em { font-style: italic; color: var(--rose-deep); font-weight: 400; }
  .modal-close {
    background: var(--milk);
    border: 2px solid var(--cream-deep);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .achievement-list, .shop-list { display: flex; flex-direction: column; gap: 10px; }
  .ach-item, .shop-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--milk);
    border-radius: 14px;
    border: 2px solid var(--cream-deep);
  }
  .ach-item.locked { opacity: 0.5; }
  .ach-item.unlocked { border-color: var(--mint-deep); }
  .ach-item.secret, .shop-item.secret {
    border-style: dashed;
    border-color: var(--lavender);
    background: linear-gradient(135deg, var(--milk), #F0E8F5);
  }
  .ach-item.secret .ach-name, .shop-item.secret .ach-name {
    font-style: italic;
    color: var(--lavender);
  }
  .shop-item.locked-item .ach-name {
    color: var(--cocoa-soft);
  }
  .shop-item.locked-item .shop-icon {
    background: var(--cream-deep);
    opacity: 0.6;
  }
  .ach-icon, .shop-icon {
    font-size: 28px;
    width: 44px;
    height: 44px;
    background: var(--cream);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  .ach-text { flex: 1; min-width: 0; }
  .ach-name { font-family: 'Fraunces', serif; font-weight: 700; font-size: 15px; }
  .ach-desc { font-size: 12px; color: var(--cocoa-soft); }
  .shop-buy {
    background: var(--cocoa);
    color: var(--cream);
    border: none;
    padding: 8px 14px;
    border-radius: 100px;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 12px;
    cursor: pointer;
  }
  .shop-buy:disabled { background: var(--cream-deep); color: var(--cocoa-soft); cursor: not-allowed; }
  .shop-buy.owned { background: var(--mint-deep); }
  .shop-buy.equipped { background: var(--rose-deep); }

  /* Tutorial */
  .tutorial-modal { max-width: 360px; text-align: center; }
  .tutorial-page h3 {
    font-family: 'Fraunces', serif;
    font-size: 22px;
    font-weight: 900;
    color: var(--cocoa); /* A233: was inheriting the shared light body text on the cream modal */
    margin-bottom: 10px;
  }
  .tutorial-page h3 em { font-style: italic; color: var(--rose-deep); font-weight: 400; }
  .tutorial-page p {
    font-size: 14px;
    color: var(--cocoa-soft);
    line-height: 1.7;
    margin-bottom: 10px;
  }
  .tutorial-page .tut-icon {
    font-size: 48px;
    margin-bottom: 12px;
    display: block;
  }
  .tutorial-page .tut-step {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--rose-deep);
    margin-bottom: 8px;
  }

  /* Keyboard cursor */
  .tile.kb-cursor {
    box-shadow: 0 0 0 3px var(--sun), 0 0 0 5px rgba(245, 199, 106, 0.4), var(--shadow-tile) !important;
    z-index: 4;
  }

  /* Seasonal tint overlay */
  .seasonal-tint {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    opacity: 0.12;
    mix-blend-mode: overlay;
    transition: background 1s ease;
  }
  .seasonal-tint.spring { background: linear-gradient(180deg, #FFB7C5, #C8E6C9); }
  .seasonal-tint.summer { background: linear-gradient(180deg, #B3E5FC, #FFF9C4); }
  .seasonal-tint.autumn { background: linear-gradient(180deg, #FFAB91, #FFE0B2); }
  .seasonal-tint.winter { background: linear-gradient(180deg, #B3E5FC, #E1BEE7); }

  /* Tappable avatar */
  .guest-avatar { cursor: pointer; }

  /* Shop tabs */
  .shop-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px dashed var(--cream-deep);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .shop-tab {
    background: var(--milk);
    border: 2px solid var(--cream-deep);
    padding: 8px 6px;
    border-radius: 12px;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    font-size: 10px;
    font-weight: 700;
    color: var(--cocoa-soft);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex: 1;
    min-width: 56px;
    transition: all 0.2s ease;
  }
  .shop-tab.active {
    background: var(--cocoa);
    color: var(--cream);
    border-color: var(--cocoa);
  }
  .shop-tab-icon { font-size: 18px; line-height: 1; }
  .shop-tab-label { font-size: 10px; }
  .shop-tab-count {
    font-size: 9px;
    opacity: 0.7;
    background: rgba(255,255,255,0.15);
    padding: 1px 6px;
    border-radius: 100px;
  }
  .shop-tab.active .shop-tab-count { background: rgba(255,255,255,0.2); }

  /* Cafe background variants */
  .cafe-scene.cafe_garden  { background: linear-gradient(180deg, #C8E6C9 0%, #81C784 50%, #4CAF50 100%); }
  .cafe-scene.cafe_beach   { background: linear-gradient(180deg, #B3E5FC 0%, #4FC3F7 50%, #FFE0B2 100%); }
  .cafe-scene.cafe_library { background: linear-gradient(180deg, #5D4037 0%, #795548 50%, #3E2723 100%); }
  .cafe-scene.cafe_space   { background: radial-gradient(ellipse at center, #1a0a3e 0%, #03010f 70%); }
  .cafe-scene.cafe_space::before,
  .cafe-scene.cafe_space::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
      radial-gradient(1px 1px at 20% 30%, white, transparent),
      radial-gradient(1px 1px at 80% 20%, white, transparent),
      radial-gradient(1px 1px at 40% 70%, white, transparent),
      radial-gradient(1.5px 1.5px at 60% 40%, white, transparent),
      radial-gradient(1px 1px at 15% 80%, white, transparent),
      radial-gradient(1px 1px at 90% 60%, white, transparent),
      radial-gradient(1.5px 1.5px at 50% 15%, white, transparent),
      radial-gradient(1px 1px at 75% 85%, white, transparent),
      radial-gradient(1px 1px at 30% 50%, white, transparent);
    animation: twinkle 4s ease-in-out infinite;
    pointer-events: none;
  }
  .cafe-scene.cafe_space::after {
    animation-delay: 2s;
    background-image:
      radial-gradient(1px 1px at 10% 15%, white, transparent),
      radial-gradient(1px 1px at 65% 25%, white, transparent),
      radial-gradient(1.5px 1.5px at 35% 85%, white, transparent),
      radial-gradient(1px 1px at 85% 45%, white, transparent),
      radial-gradient(1px 1px at 45% 60%, white, transparent);
  }
  @keyframes twinkle {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
  }

  /* Tile skin variants */
  .board.skin_pastel .tile { background: #FFF0F5; }
  .board.skin_neon .tile {
    background: #1a0a2e;
    box-shadow: 0 0 8px rgba(244, 182, 194, 0.6), var(--shadow-tile);
  }
  .board.skin_neon .tile svg { filter: drop-shadow(0 0 4px currentColor); }

.jvds-strip.open ~ * { transition: margin-top .25s ease; }
/* ---------------------------------------------------------- */