/* Inimene linnas — kolitud digiaed.ee staatiliselt saidilt (2026-10-01).
   GENEREERITUD algsest index.html-ist; mänguaja piirang (admin.php) eemaldatud. */
  * { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    background: #6db840;
    font-family: 'Fredoka', system-ui, sans-serif;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior: none;
  }
  main#sisu { display: block; width: 100%; height: 100%; }
  #game { width: 100%; height: 100%; display: block; }
  canvas { display: block; }

  /* HUD */
  #hud {
    position: fixed;
    /* max(): ilma lõiguta seadmel on env() 0, mitte varuväärtus — HUD kleepus servale */
    top: max(10px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    padding-top: 6px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    pointer-events: none;
    z-index: 10;
  }
  #inventory {
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(10px);
    border-radius: 22px;
    padding: 8px 14px;
    display: flex;
    flex-wrap: nowrap; /* üks rida: kõrgus püsib ja ülesandepaneel ei jää alla */
    gap: 6px;
    min-height: 42px;
    font-size: 26px;
    line-height: 1;
    box-shadow: 0 4px 14px rgba(0,0,0,0.18);
    align-items: center;
  }
  #inventory .empty { color: #666; font-size: 14px; font-style: italic; font-weight: 500; }
  #inventory .item { display: inline-flex; animation: pop 0.4s ease-out; }
  @keyframes pop { 0% { transform: scale(0); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }

  .hud-btn {
    background: rgba(255,255,255,0.92);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 22px;
    pointer-events: auto;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
    font-family: inherit;
    color: #2a1410; /* tume teema ei tohi nupu (hele taust) teksti heledaks muuta */
  }

  #task-panel {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(255, 250, 235, 0.96);
    color: #2a1410;
    padding: 8px 14px 8px 10px;
    border-radius: 28px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 16px;
    pointer-events: none;
    z-index: 12;
    box-shadow: 0 6px 20px rgba(0,0,0,0.28);
    border: 3px solid #ffd84a;
    opacity: 0;
    transition: opacity 0.4s, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
  }
  #task-panel.show { opacity: 1; transform: translateX(-50%) translateY(0); }
  #task-panel .ico {
    font-size: 26px;
    background: #ffd84a;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  #task-panel .label { font-size: 10px; color: #999; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 800; }
  #task-panel .desc { font-size: 15px; }
  /* Puudutus kordab hääljuhist */
  #task-panel.show { pointer-events: auto; cursor: pointer; }
  #task-panel:focus-visible { outline: 3px solid #2c7da0; outline-offset: 3px; }
  #task-panel .say { display: none; font-size: 18px; margin-left: 2px; }
  #task-panel.can-say .say { display: block; }
  #interior-say {
    margin-left: 10px; vertical-align: middle;
    background: #ffd84a; border: none; border-radius: 50%;
    width: 40px; height: 40px; font-size: 20px; cursor: pointer;
    box-shadow: 0 3px 0 #c9a52a; color: #2a1410;
  }
  #interior-say:active { transform: translateY(2px); box-shadow: 0 1px 0 #c9a52a; }
  #interior-say[hidden] { display: none; }
  #task-panel .prog { background: #ffd84a; color: #2a1410; padding: 3px 8px; border-radius: 12px; font-size: 13px; font-weight: 900; margin-left: 6px; display: none; }

  #action-btn {
    position: fixed;
    right: max(16px, env(safe-area-inset-right, 16px));
    bottom: max(20px, env(safe-area-inset-bottom, 20px));
    width: 86px;
    height: 86px;
    border-radius: 50%;
    background: linear-gradient(180deg, #ffd84a 0%, #ffaa00 100%);
    border: 4px solid #fff;
    color: #4a2c00;
    font-weight: 900;
    font-size: 16px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3), inset 0 2px 0 rgba(255,255,255,0.5);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 2px;
    font-family: inherit;
    pointer-events: auto;
    z-index: 15;
    text-align: center;
    line-height: 1.1;
    padding: 0 6px;
  }
  #action-btn:active { transform: scale(0.93); }
  /* Sireen (ainult politseiautot juhtides) — tegevusnupu kohal */
  #siren-btn {
    position: fixed;
    right: calc(max(16px, env(safe-area-inset-right, 16px)) + 13px);
    bottom: calc(max(20px, env(safe-area-inset-bottom, 20px)) + 98px);
    width: 60px; height: 60px; border-radius: 50%;
    background: #1e3a8a; border: 4px solid #fff; color: #fff;
    font-size: 26px; cursor: pointer; pointer-events: auto; z-index: 15;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    display: none; align-items: center; justify-content: center; font-family: inherit;
  }
  #siren-btn.show { display: flex; }
  #siren-btn:active { transform: scale(0.93); }
  /* Vilkurid põlevad: nupp vilgub sinise ja punase vahel */
  #siren-btn.on { animation: sirenblink 0.5s steps(1) infinite; }
  @keyframes sirenblink { 0% { background: #1d4ed8; } 50% { background: #dc2626; } }
  @media (prefers-reduced-motion: reduce) { #siren-btn.on { animation: none; background: #dc2626; } }

  /* Mänguasjapood (kaart on alati hele — sama nagu teised sisevaated) */
  .shop-coins { font-size: 26px; font-weight: 900; color: #8a5a00; margin: 4px 0 10px; }
  .shop-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .shop-item {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 10px 4px; border-radius: 16px; border: 3px solid #e8d9a0; background: #fff;
    color: #2a1410; font-family: inherit; cursor: pointer; min-height: 120px;
  }
  .shop-item:focus-visible { outline: 4px solid #3a86ff; outline-offset: 2px; }
  .shop-ico { font-size: 40px; line-height: 1.1; }
  .shop-name { font-size: 14px; font-weight: 700; text-align: center; line-height: 1.15; }
  .shop-price { font-size: 17px; font-weight: 900; color: #8a5a00; }
  .shop-item.poor { opacity: 0.5; }
  .shop-item.owned { background: #e6f9e4; border-color: #3da253; }
  .shop-item.owned .shop-price { color: #1e7a36; font-size: 14px; }
  .shop-item.wrong { animation: igshake 0.35s; border-color: #ff5d5d; }
  /* Ostetud asja asemele riiulile tulnud uus ese */
  .shop-item.new { animation: shopnew 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); border-color: #ffb703; }
  @keyframes shopnew { 0% { transform: scale(0.3) rotate(-8deg); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
  @media (prefers-reduced-motion: reduce) { .shop-item.new { animation: none; } }
  .shop-owned { margin-top: 12px; font-size: 20px; color: #5a3a1c; font-weight: 700; word-break: break-word; }
  @media (max-width: 400px) { .shop-grid { gap: 6px; } .shop-ico { font-size: 32px; } .shop-name { font-size: 12px; } .shop-item { min-height: 104px; } }
  @media (max-width: 640px) {
    #siren-btn { width: 52px; height: 52px; font-size: 22px; right: calc(max(16px, env(safe-area-inset-right, 16px)) + 11px); bottom: calc(max(20px, env(safe-area-inset-bottom, 20px)) + 156px); } /* teate (bottom 132px) kohale */
  }
  #action-btn.show { display: flex; }
  #action-btn .a-ico { font-size: 30px; }
  #action-btn .a-txt { font-size: 11px; font-weight: 800; }

  #message {
    position: fixed;
    bottom: 140px;
    left: 50%;
    transform: translateX(-50%) translateY(140px);
    background: rgba(255,255,255,0.96);
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 20px;
    font-weight: 700;
    color: #222;
    box-shadow: 0 6px 24px rgba(0,0,0,0.22);
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    z-index: 20;
    text-align: center;
    width: max-content;
    max-width: min(92vw, 560px); /* pikk teade murdub, mitte ei jookse ekraanilt välja */
  }
  #message.show { opacity: 1; transform: translateX(-50%) translateY(0); }

  #bottom-hint {
    position: fixed;
    bottom: max(16px, env(safe-area-inset-bottom, 16px));
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.6);
    color: #fff;
    padding: 8px 16px;
    border-radius: 22px;
    font-size: 14px;
    font-weight: 700;
    pointer-events: none;
    z-index: 15;
    opacity: 0;
    transition: opacity 0.2s;
    white-space: nowrap;
  }
  #bottom-hint.show { opacity: 1; }
  /* Puuteseadmel pole tühikuklahvi; sama info on tegevusnupul endal (ikoon + tegusõna) */
  @media (hover: none) and (pointer: coarse) { #bottom-hint { display: none; } }
  #bottom-hint kbd { background: #fff; color: #000; padding: 2px 7px; border-radius: 5px; margin: 0 4px; font-weight: 800; font-size: 12px; }

  /* Statistika HUD */
  #hud-left { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
  #stats { display: flex; gap: 6px; }
  .chip {
    background: rgba(255,255,255,0.92);
    border-radius: 18px;
    padding: 5px 13px;
    font-weight: 800;
    font-size: 15px;
    color: #4a2c00;
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
  }

  /* Hoone sisevaade + minimängud */
  #interior {
    position: fixed; inset: 0;
    background: rgba(25, 12, 5, 0.55);
    display: none; align-items: center; justify-content: center;
    z-index: 50; padding: 16px;
  }
  #interior.show { display: flex; }
  #interior-card {
    background: #fffbe9;
    color: #2a1410; /* kaart on hele ka tumedas teemas — muidu pärib .ig-big saidi valge teksti */
    border: 4px solid #ffd84a;
    border-radius: 26px;
    max-width: 500px; width: 100%;
    max-height: 86vh; overflow-y: auto;
    padding: 20px 18px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    animation: cardpop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  @keyframes cardpop { 0% { transform: scale(0.7); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
  #interior-head { font-size: 24px; font-weight: 800; color: #2a1410; margin-bottom: 10px; }
  #interior-head #interior-icon { font-size: 30px; margin-right: 8px; }
  .ig-title { font-size: 17px; font-weight: 700; color: #5a3a1c; }
  .ig-big { font-size: 38px; letter-spacing: 5px; margin: 12px 0; line-height: 1.35; word-break: break-word; }
  .ig-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
  .ig-grid.wide { grid-template-columns: repeat(4, 1fr); }
  .ig-btn {
    font-size: 32px; padding: 14px 6px;
    border-radius: 16px; border: 3px solid #e8d9a0;
    background: #fff; cursor: pointer; font-family: inherit; font-weight: 800;
    transition: transform 0.1s;
    color: #2a1410;
  }
  .ig-btn:active { transform: scale(0.93); }
  .ig-btn.correct { background: #c8f7c5; border-color: #3da253; }
  .ig-btn.wrong { animation: igshake 0.35s; border-color: #ff5d5d; }
  .ig-btn:disabled { cursor: default; }
  /* Vanglas vale vastuse järel: õige vastus vilgub (laps näeb, mis oli õige) */
  .ig-btn.hint { background: #c8f7c5; border-color: #3da253; animation: ighint 0.5s ease-in-out 5 alternate; }
  @keyframes ighint { from { transform: scale(1); box-shadow: 0 0 0 0 rgba(61,162,83,0.6); } to { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(61,162,83,0); } }
  @media (prefers-reduced-motion: reduce) { .ig-btn.hint { animation: none; } }
  /* Liiklusküsimuste piltvastused (emoji või SVG) */
  .ig-pic { display: flex; align-items: center; justify-content: center; min-height: 86px; }
  .ig-pic svg { width: 72px; height: 72px; display: block; }
  /* Emoji-vastus sama suur kui joonistatud pilt — 32 px emojil (🧍, 🙋) ei paistnud detailid välja */
  .ig-pic.emo { font-size: 52px; line-height: 1; }
  .ig-big svg { width: 54px; height: 54px; display: inline-block; vertical-align: middle; }
  .ig-wide { font-size: 22px; padding: 14px 30px; background: #c8f7c5; border-color: #3da253; }
  @keyframes igshake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); } }
  .ig-progress { font-weight: 900; color: #b8860b; margin-top: 8px; font-size: 15px; }
  .ig-result { font-weight: 800; font-size: 19px; color: #3da253; margin-top: 8px; min-height: 24px; }
  /* Loomaaia toitmismäng: loom suurelt (õige vastuse järel toit kõrval) */
  .ig-big.ig-animal { font-size: 64px; letter-spacing: 0; line-height: 1.1; }
  /* 112-mäng ja haigla: olukord / patsient suurelt */
  .ig-big.ig-scene { font-size: 60px; letter-spacing: 4px; line-height: 1.1; }
  /* 112-mäng: valitav number (sihtnumber tuhmilt, vajutatud numbrid süttivad) ja telefoni klahvistik */
  .ig-dial { display: flex; justify-content: center; gap: 10px; margin: 10px 0 4px; }
  .ig-dial span { width: 54px; height: 64px; display: flex; align-items: center; justify-content: center;
    font-size: 44px; font-weight: 900; border-radius: 12px; border: 3px dashed #e8d9a0; color: #d6c690; background: #fff; }
  .ig-dial span.on { color: #fff; background: #e63946; border: 3px solid #b91c1c; }
  .ig-keypad { display: grid; grid-template-columns: repeat(3, 72px); justify-content: center; gap: 8px; margin: 12px 0 4px; }
  .ig-key { font-size: 30px; padding: 8px 0; border-radius: 50%; aspect-ratio: 1; }
  .ig-keypad .ig-key:last-child { grid-column: 2; }
  /* Lennujaama turvakontroll: kott sõidab lindil läbi skanneri */
  .ig-belt {
    position: relative; height: 70px; margin: 14px 0;
    border-radius: 12px; border: 3px solid #64748b;
    background: repeating-linear-gradient(90deg, #475569 0 14px, #334155 14px 28px);
    overflow: hidden;
  }
  .ig-bag { position: absolute; left: 6px; top: 8px; font-size: 44px; line-height: 1; transition: left 1.3s ease-in-out; }
  .ig-belt.go .ig-bag { left: calc(100% - 56px); }
  .ig-scan { position: absolute; left: 50%; top: 4px; transform: translateX(-50%); font-size: 30px; opacity: 0.85; }
  @media (prefers-reduced-motion: reduce) { .ig-bag { transition: none; } }
  #interior-exit {
    margin-top: 12px;
    background: #ff5d5d; color: #fff;
    border: none; border-radius: 40px;
    padding: 13px 34px;
    font-size: 18px; font-weight: 800;
    font-family: inherit; cursor: pointer;
    box-shadow: 0 4px 0 #b13e3e;
  }
  #interior-exit:active { transform: translateY(3px); box-shadow: 0 1px 0 #b13e3e; }
  #reset-btn {
    background: rgba(255,255,255,0.22);
    color: #fff;
    border: 2px solid rgba(255,255,255,0.6);
    border-radius: 30px;
    padding: 8px 22px;
    font-size: 14px; font-weight: 700;
    font-family: inherit; cursor: pointer;
    display: none;
  }

  #start-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(180deg, #56c5ee 0%, #9adff5 45%, #a8d97a 55%, #6fb84a 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Tsentreerimine auto-veeristega: madalal ekraanil (telefon rõhtsalt) kerib sisu,
       justify-content: center lõikaks pealkirja ülevalt ära */
    justify-content: flex-start;
    overflow-y: auto;
    gap: 22px;
    padding: 24px;
    z-index: 100;
    transition: opacity 0.45s ease, visibility 0s linear 0.45s;
    text-align: center;
  }
  #start-title { margin-top: auto; }
  #loading { margin-bottom: auto; }
  #start-screen.hidden { opacity: 0; pointer-events: none; visibility: hidden; }
  #start-title { font-size: 54px; font-weight: 900; color: white; text-shadow: 0 3px 0 #2c7da0, 0 6px 0 #1f5d76, 0 10px 24px rgba(0,0,0,0.35); }
  #start-subtitle { color: white; font-size: 17px; max-width: 480px; text-shadow: 0 2px 6px rgba(0,0,0,0.28); font-weight: 600; line-height: 1.5; }
  #start-btn {
    background: #ff5d5d;
    color: white;
    border: none;
    padding: 18px 56px;
    font-size: 32px;
    font-weight: 900;
    border-radius: 60px;
    cursor: pointer;
    box-shadow: 0 6px 0 #b13e3e, 0 12px 30px rgba(0,0,0,0.3);
    font-family: inherit;
  }
  #start-btn:active { transform: translateY(5px); box-shadow: 0 1px 0 #b13e3e, 0 4px 18px rgba(0,0,0,0.3); }
  #loading { color: white; font-size: 14px; opacity: 0.85; font-weight: 600; }
  .controls-hint { color: white; font-size: 14px; opacity: 0.9; font-weight: 600; line-height: 1.7; }
  .controls-hint kbd { background: rgba(255,255,255,0.85); color: #1a3550; padding: 1px 8px; border-radius: 5px; margin: 0 3px; font-weight: 800; font-size: 12px; }

  @media (max-width: 640px) {
    #start-title { font-size: 36px; }
    #start-btn { padding: 14px 40px; font-size: 24px; }
    .hud-btn { width: 42px; height: 42px; font-size: 18px; }
    #action-btn { width: 74px; height: 74px; }
    #inventory { font-size: 22px; padding: 6px 12px; min-height: 36px; }
    #message { font-size: 16px; padding: 10px 20px; bottom: 100px; }
    #task-panel { font-size: 13px; padding: 6px 10px 6px 8px; top: 60px; }
    #task-panel .ico { font-size: 22px; width: 32px; height: 32px; }
    #task-panel .desc { font-size: 13px; }
    .chip { font-size: 13px; padding: 4px 10px; }
    .ig-btn { font-size: 26px; padding: 10px 4px; }
    .ig-pic.emo { font-size: 44px; }
    .ig-pic svg { width: 60px; height: 60px; }
    .ig-big { font-size: 30px; letter-spacing: 3px; }
    #interior-card { padding: 14px 12px; }
  }
  /* Kitsal ekraanil ei mahu ülesandepaneel HUD-i kõrvale — tuleb selle alla */
  @media (max-width: 820px) {
    #task-panel { top: calc(max(10px, env(safe-area-inset-top)) + 84px); }
  }
  @media (max-width: 640px) {
    #task-panel { top: calc(max(10px, env(safe-area-inset-top)) + 80px); }
    #message { bottom: 132px; } /* kompassi (all vasakul) ja tegevusnupu kohal */
  }
  /* Madal ekraan (telefon rõhtsalt): ülesandepaneel HUD-i alla vasakule — keskel kattis
     see mängija, sest kaamera hoiab tegelast ekraani keskel */
  @media (max-height: 520px) {
    #task-panel { top: calc(max(10px, env(safe-area-inset-top)) + 90px); left: max(10px, env(safe-area-inset-left)); transform: translateY(-20px); }
    #task-panel.show { transform: translateY(0); }
    /* teade alla kompassi ja tegevusnupu vahele, mitte tegelase peale */
    #message { bottom: max(14px, env(safe-area-inset-bottom)); max-width: calc(100vw - 260px); font-size: 15px; }
  }
  /* Madal ekraan (telefon rõhtsalt): kompaktsem algusekraan, tagasilink ei kata pealkirja */
  @media (max-height: 520px) {
    #start-screen { gap: 12px; padding-top: 64px; }
    #start-title { font-size: 36px; }
    #start-subtitle { font-size: 14px; max-width: 620px; }
    #start-btn { padding: 12px 40px; font-size: 24px; }
  }
  /* Paus: nupp HUD-is heli kõrval, ekraan katab ka sisevaate (aga mitte algusekraani) */
  #hud-right { display: flex; gap: 8px; }
  #pause-screen {
    position: fixed; inset: 0; z-index: 90;
    background: rgba(20, 30, 60, 0.6);
    display: flex; align-items: center; justify-content: center; padding: 16px;
  }
  #pause-screen[hidden] { display: none; }
  /* Kaart: minimap ainult laial ekraanil (telefonis kataks mänguala) — seal on 🗺️ nupp */
  #minimap {
    position: fixed; z-index: 10;
    top: calc(max(10px, env(safe-area-inset-top)) + 68px); right: max(10px, env(safe-area-inset-right));
    width: 184px; height: 184px; padding: 0; display: none;
    border: 4px solid rgba(255,255,255,0.95); border-radius: 22px; overflow: hidden;
    background: #2b5a24; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  }
  #minimap canvas { width: 176px; height: 176px; }
  #minimap:focus-visible, #map-btn:focus-visible, #map-close:focus-visible { outline: 3px solid #2c7da0; outline-offset: 3px; }
  @media (min-width: 900px) and (min-height: 600px) {
    #minimap:not([hidden]) { display: block; }
    #map-btn { display: none; }
  }
  #map-screen {
    position: fixed; inset: 0; z-index: 85;
    background: rgba(20, 30, 60, 0.7);
    display: flex; align-items: center; justify-content: center; padding: 12px;
  }
  #map-screen[hidden] { display: none; }
  #map-card {
    position: relative; background: #fffbe9; border: 4px solid #ffd84a; border-radius: 22px; padding: 8px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4); animation: cardpop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  #map-canvas { display: block; border-radius: 14px; }
  #map-close {
    position: absolute; top: -16px; right: -16px; width: 52px; height: 52px; border-radius: 50%;
    border: 3px solid #fff; background: #ff5d5d; color: #fff; font-size: 22px; font-weight: 900;
    font-family: inherit; cursor: pointer; box-shadow: 0 4px 0 #b13e3e;
  }
  #pause-card {
    background: #fffbe9; color: #2a1410;
    border: 4px solid #ffd84a; border-radius: 26px;
    padding: 24px 28px; text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    animation: cardpop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  #pause-title { font-size: 34px; font-weight: 900; }
  #resume-btn {
    background: #3da253; color: #fff; border: none; border-radius: 60px;
    padding: 16px 48px; font-size: 28px; font-weight: 900; font-family: inherit; cursor: pointer;
    box-shadow: 0 5px 0 #2a7a3c;
  }
  #resume-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #2a7a3c; }
  #resume-btn:focus-visible, #pause-btn:focus-visible { outline: 3px solid #2c7da0; outline-offset: 3px; }
  #pause-home { color: #2c5d8a; font-weight: 800; font-size: 15px; }
  /* Hoia-all-nupp (nullimine): riba täitub 2 s jooksul */
  .hold-btn { position: relative; overflow: hidden; -webkit-touch-callout: none; touch-action: none; }
  .hold-btn .hold-fill {
    position: absolute; inset: 0; background: rgba(255, 93, 93, 0.45);
    transform: scaleX(0); transform-origin: left center; pointer-events: none;
  }
  .hold-btn .hold-txt { position: relative; }
  #pause-reset {
    background: #fff; color: #7a2a2a; border: 2px solid #f3b4b4; border-radius: 30px;
    padding: 8px 18px; font-size: 14px; font-weight: 700; font-family: inherit; cursor: pointer;
  }
  #pause-reset:focus-visible, #reset-btn:focus-visible { outline: 3px solid #2c7da0; outline-offset: 3px; }
  /* Tegelaskuju valik (algusekraan, paus) */
  #start-row { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; }
  .char-open {
    display: inline-flex; align-items: center; gap: 8px;
    background: #fffbe9; color: #2a1410; border: 3px solid #ffd84a; border-radius: 22px;
    padding: 6px 14px 6px 8px; font-family: inherit; font-size: 20px; font-weight: 800; cursor: pointer;
    box-shadow: 0 4px 0 #d9b43a;
  }
  .char-open:active { transform: translateY(3px); box-shadow: 0 1px 0 #d9b43a; }
  .char-open:focus-visible, #char-card button:focus-visible { outline: 3px solid #2c7da0; outline-offset: 3px; }
  .char-open canvas { width: 48px; height: 60px; image-rendering: pixelated; }
  #pause-char { font-size: 17px; }
  #char-screen {
    position: fixed; inset: 0; z-index: 110;
    background: rgba(20, 30, 60, 0.6);
    display: flex; align-items: center; justify-content: center;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }
  #char-screen[hidden] { display: none; }
  #char-card {
    background: #fffbe9; color: #2a1410; border: 4px solid #ffd84a; border-radius: 26px;
    padding: 16px 18px; max-width: 640px; width: 100%; max-height: 100%; overflow-y: auto;
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    animation: cardpop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  #char-title { font-size: 26px; font-weight: 900; display: flex; align-items: center; gap: 10px; }
  #char-say { background: #fff; border: 2px solid #e9dca8; border-radius: 50%; width: 40px; height: 40px; font-size: 18px; cursor: pointer; }
  #char-body { display: flex; gap: 18px; align-items: center; justify-content: center; flex-wrap: wrap; }
  #char-preview { display: flex; flex-direction: column; align-items: center; gap: 8px; }
  #char-canvas { width: 144px; height: 180px; image-rendering: pixelated; background: radial-gradient(circle at 50% 70%, #cdeeb1 0 55%, transparent 56%); }
  #char-random { background: #fff; border: 2px solid #e9dca8; border-radius: 14px; font-size: 26px; width: 56px; height: 48px; cursor: pointer; }
  #char-rows { display: flex; flex-direction: column; gap: 8px; }
  .char-row { display: flex; align-items: center; gap: 8px; }
  .char-ico { font-size: 22px; width: 30px; text-align: center; flex: none; }
  .char-opts { display: flex; gap: 6px; flex-wrap: wrap; }
  .char-opt {
    width: 44px; height: 44px; border-radius: 12px; border: 3px solid #e9dca8; background: #fff;
    padding: 0; cursor: pointer; display: flex; align-items: center; justify-content: center;
  }
  .char-opt canvas { width: 32px; height: 40px; image-rendering: pixelated; }
  .char-opt .sw { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(0,0,0,0.25); }
  .char-opt[aria-pressed="true"] { border-color: #ff5d5d; box-shadow: 0 0 0 3px #ffd0d0; transform: scale(1.06); }
  #char-done {
    background: #3da253; color: #fff; border: none; border-radius: 60px;
    padding: 12px 44px; font-size: 26px; font-weight: 900; font-family: inherit; cursor: pointer;
    box-shadow: 0 5px 0 #2a7a3c;
  }
  #char-done:active { transform: translateY(4px); box-shadow: 0 1px 0 #2a7a3c; }
  /* Kitsas telefon: kuus särgivärvi peavad mahtuma ühte ritta */
  @media (max-width: 420px) {
    #char-card { padding: 14px 10px; }
    .char-opts { gap: 4px; }
    .char-opt { width: 38px; height: 38px; }
    .char-opt canvas { width: 28px; height: 35px; }
    .char-opt .sw { width: 22px; height: 22px; }
    #char-canvas { width: 96px; height: 120px; }
    #char-title { font-size: 22px; }
  }
  /* Telefon rõhtsalt: eelvaade vasakule, read paremale, kõik ühele ekraanile */
  @media (max-height: 520px) {
    #char-card { padding: 8px 14px; gap: 6px; }
    #char-title { font-size: 18px; }
    #char-say { width: 32px; height: 32px; font-size: 15px; }
    #char-canvas { width: 96px; height: 120px; }
    #char-body { flex-wrap: nowrap; }
    .char-opt { width: 36px; height: 36px; border-width: 2px; }
    .char-opt canvas { width: 26px; height: 33px; }
    .char-opt .sw { width: 22px; height: 22px; }
    #char-rows { gap: 4px; }
    #char-done { padding: 6px 36px; font-size: 20px; }
  }
  /* Kooli lugemisülesanded: kirjutatud sõnad ja pildid */
  .ig-word { font-size: 26px; letter-spacing: 2px; padding: 16px 6px; }
  .ig-img { display: flex; align-items: center; justify-content: center; min-height: 96px; padding: 8px; }
  .ig-img img { width: 72px; height: 72px; object-fit: contain; display: block; }
  .ig-grid.ig-stack { grid-template-columns: 1fr; max-width: 360px; margin-left: auto; margin-right: auto; }
  .ig-big.ig-long { font-size: 26px; letter-spacing: 1px; }
  /* Toidupoe ostunimekiri (sõnad), kohviku tellimus, postiljoni kiri, koeratoit.
     Kaart on ka tumedas teemas hele (#interior-card) — värvid on sellele pinnale. */
  .ig-shoplist { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 12px 0; }
  .ig-listword { font-size: 24px; font-weight: 800; letter-spacing: 2px; padding: 6px 14px; border-radius: 12px;
    background: #fff; border: 3px dashed #e8d9a0; color: #2a1410; }
  .ig-listword.done { opacity: 0.45; border-style: solid; letter-spacing: 1px; font-size: 18px; }
  .ig-listword.hint { border-color: #3da253; background: #e9fbe7; animation: ighint 0.5s ease-in-out 4 alternate; }
  .ig-order { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 10px 0; }
  .ig-guest { font-size: 46px; }
  .ig-bubble { font-size: 44px; background: #fff; border: 3px solid #e8d9a0; border-radius: 22px; padding: 4px 16px; position: relative; }
  .ig-bubble::before { content: ''; position: absolute; left: -12px; top: 50%; margin-top: -8px;
    border: 8px solid transparent; border-right: 10px solid #e8d9a0; border-left: 0; }
  .ig-post, .ig-dogfood { margin-top: 14px; padding-top: 12px; border-top: 2px dashed #e8d9a0; }
  .ig-letter { display: inline-block; margin-top: 8px; font-size: 30px; font-weight: 800; letter-spacing: 3px;
    background: #fff; border: 3px solid #e8d9a0; border-radius: 10px; padding: 6px 18px; color: #2a1410; }
  .ig-buy { font-size: 22px; padding: 10px 18px; margin-top: 8px; }
  .ig-buy b { color: #b8860b; }
  #letter-chip[hidden], #fuel-chip[hidden], #job-chip[hidden] { display: none; }
  /* Ametitöö (kiirabi, tuletõrje, takso, veoauto): kuhu sõita — ikoon + hoone silt */
  #job-chip { background: #fff3c4; border: 2px solid #f59e0b; font-size: 17px; }
  /* Kütusenäidik (autos) omaette real statistika all — statistika rida on telefonis juba täis.
     Otsakorral punane ja vilgub. */
  #hud .chip { white-space: nowrap; }
  .fuel-bar { display: inline-block; width: 54px; height: 11px; border-radius: 6px; background: rgba(0,0,0,0.18);
    vertical-align: middle; overflow: hidden; margin-left: 2px; }
  .fuel-bar i { display: block; height: 100%; width: 100%; background: #3da253; border-radius: 6px; transition: width 0.3s; }
  #fuel-chip.low { background: #e63946; color: #fff; animation: fuelblink 0.8s ease-in-out infinite alternate; }
  #fuel-chip.low .fuel-bar i { background: #fff; }
  @keyframes fuelblink { from { opacity: 1; } to { opacity: 0.55; } }
  @media (prefers-reduced-motion: reduce) { #fuel-chip.low { animation: none; } }
  /* Jalgpalli tablo (nähtav ainult väljakul) */
  #scoreboard { position: fixed; top: 132px; left: 50%; transform: translateX(-50%); z-index: 20;
    background: #1f2937; color: #fde68a; font-weight: 900; font-size: 20px; letter-spacing: 1px;
    padding: 6px 16px; border-radius: 14px; border: 3px solid #fde68a; box-shadow: 0 6px 18px rgba(0,0,0,0.3);
    white-space: nowrap; pointer-events: none; }
  #scoreboard[hidden] { display: none; }
  #letter-chip b { letter-spacing: 1px; }
  @media (max-width: 640px) {
    #scoreboard { top: 160px; font-size: 16px; padding: 4px 12px; }
    #fuel-chip .fuel-bar { width: 36px; }
    .ig-listword { font-size: 19px; padding: 4px 10px; }
    .ig-guest, .ig-bubble { font-size: 36px; }
    .ig-letter { font-size: 24px; }
    .ig-word { font-size: 20px; letter-spacing: 1px; padding: 12px 2px; }
    .ig-stack .ig-word { padding: 10px 6px; }
    .ig-big.ig-long { font-size: 20px; letter-spacing: 0; }
    .ig-img img { width: 60px; height: 60px; }
  }
  /* Tagasi digiaia avalehele (algusekraan) */
  #home-link { position: absolute; top: max(14px, env(safe-area-inset-top, 14px)); left: max(14px, env(safe-area-inset-left, 14px));
    color: #fff; font-weight: 800; font-size: 15px; text-decoration: none; background: rgba(0,0,0,0.22);
    border: 2px solid rgba(255,255,255,0.6); border-radius: 30px; padding: 7px 16px; }
  #home-link:hover, #home-link:focus-visible { background: rgba(0,0,0,0.35); color: #fff; }
  /* Piltide viide (CC BY / CC BY-SA): väike, aga loetav — tume pill heleda/rohelise tausta peal */
  #credits-link { color: #fff; font-size: 13px; font-weight: 600; text-decoration: underline; background: rgba(0,0,0,0.35);
    border-radius: 999px; padding: 4px 12px; max-width: 100%; line-height: 1.4; }
  #credits-link:hover, #credits-link:focus-visible { background: rgba(0,0,0,0.5); color: #fff; }
