/* Kolotoč: status, clock and the line of what happened on top; the players'
   plates; the board of tiles under its category; the stage (the wheel, or the
   keyboard while a letter is picked); the buttons. Typing a solution folds it
   to the board and the field. */
.kol{
  --kol-c0:#ffc65c;--kol-c1:#6fc3df;--kol-c2:#ef7d8f;--kol-c3:#9fd47a;
  --kol-tile:#f6f1e3;--kol-tile-ink:#1f1a26;--kol-board:#0d3b37;
  position:absolute;inset:0;margin:0 auto;max-width:640px;
  display:grid;grid-template-columns:minmax(0,1fr);
  grid-template-rows:auto auto auto auto minmax(0,1fr) auto;
  grid-template-areas:"top" "plates" "board" "form" "stage" "bar";
  overflow:hidden;padding:0 8px;
}
.kol-top{grid-area:top}.kol-plates{grid-area:plates}.kol-board{grid-area:board}.kol-form{grid-area:form}.kol-stage{grid-area:stage}.kol-bar{grid-area:bar}
.kol [hidden]{display:none!important}

/* ── top ─────────────────────────────────────────────────────────────── */
.kol-top{display:grid;justify-items:center;gap:2px;padding:6px 0 2px}
.kol-status{padding:.38em .9em;font-size:.93rem;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.kol-clock{display:flex;align-items:center;gap:6px;width:min(14rem,70%)}
.kol-barline{flex:1;height:4px;border-radius:3px;background:rgba(255,255,255,.14);overflow:hidden}
.kol-barline i{display:block;height:100%;background:var(--gold);transform-origin:left;transition:transform .1s linear}
.kol-clock b{font-size:.75rem;min-width:1.6em;text-align:right;font-variant-numeric:tabular-nums;color:var(--mist)}
.kol-clock.low .kol-barline i{background:var(--cherry)}
.kol-clock.low b{color:var(--cherry)}
.kol-say{margin:0;min-height:1.3em;max-width:100%;font-size:.84rem;line-height:1.3;text-align:center;color:var(--mist);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.kol[data-last="bankrot"] .kol-say{color:var(--cherry);font-weight:700}
.kol[data-last="solved"] .kol-say{color:var(--gold);font-weight:700}

/* ── plates ──────────────────────────────────────────────────────────── */
.kol-plates{display:flex;justify-content:center;gap:5px;padding:3px 0}
.kol-plate{
  --pc:var(--kol-c0);
  display:flex;align-items:center;gap:6px;flex:0 1 200px;min-width:0;min-height:44px;padding:3px 8px 3px 4px;
  border:1.5px solid var(--line);border-radius:999px;background:rgba(13,18,10,.3);
  transition:border-color .2s,background-color .2s;
}
.kol-plate:nth-child(2){--pc:var(--kol-c1)}.kol-plate:nth-child(3){--pc:var(--kol-c2)}.kol-plate:nth-child(4){--pc:var(--kol-c3)}
.kol-plate .ava{width:30px;height:30px;font-size:.9rem;flex:none}
.kol-who{display:grid;line-height:1.15;min-width:0;flex:1}
.kol-who .nm{font-weight:600;font-size:.86rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.kol-who .sub{font-size:.7rem;color:var(--mist);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.kol-purse.on{color:var(--gold);font-weight:700}
.kol-bank{
  flex:none;min-width:2.2em;height:1.8em;padding:0 .4em;border-radius:999px;display:grid;place-items:center;
  font-size:.86rem;font-variant-numeric:tabular-nums;background:var(--pc);color:#241a2d;
}
.kol-plate.turn{border-color:var(--pc);background:rgba(255,255,255,.08)}
.kol-plate.turn .ava{box-shadow:0 0 0 2.5px var(--pc)}
.kol-plate.best .kol-bank{box-shadow:0 0 0 2.5px var(--ivory)}
.kol-bank{grid-auto-flow:column;gap:.1em}
.kol-cur{font-size:.75em}
.kol-pp{display:none}
.kol-plates[data-n="3"] .kol-plate,.kol-plates[data-n="4"] .kol-plate{flex:1 1 0;padding-right:4px;gap:4px}
/* three or four on a phone: a plate of two lines (avatar and points, then the name); this round's purse
   rides on the plate's top edge */
@media (max-width:520px){
  .kol-plates[data-n="3"],.kol-plates[data-n="4"]{padding-top:7px}
  .kol-plates[data-n="3"] .kol-plate,.kol-plates[data-n="4"] .kol-plate{
    position:relative;display:grid;grid-template-columns:auto minmax(0,1fr);grid-template-areas:"ava bank" "who who";
    align-items:center;row-gap:1px;column-gap:3px;min-height:0;padding:3px 5px 2px;border-radius:12px;
  }
  .kol-plates[data-n="3"] .ava,.kol-plates[data-n="4"] .ava{grid-area:ava;width:26px;height:26px;font-size:.78rem}
  .kol-plates[data-n="3"] .kol-bank,.kol-plates[data-n="4"] .kol-bank{grid-area:bank;justify-self:end;font-size:.76rem;min-width:1.8em;height:1.6em;padding:0 .3em}
  .kol-plates[data-n="3"] .kol-who,.kol-plates[data-n="4"] .kol-who{grid-area:who;text-align:center}
  .kol-plates[data-n="3"] .kol-who .nm,.kol-plates[data-n="4"] .kol-who .nm{font-size:.72rem}
  .kol-plates[data-n="3"] .kol-who .sub,.kol-plates[data-n="4"] .kol-who .sub{display:none}
  .kol-plates[data-n="3"] .kol-pp.on,.kol-plates[data-n="4"] .kol-pp.on{
    display:block;position:absolute;top:-8px;left:50%;transform:translateX(-50%);z-index:1;
    padding:0 .45em;border-radius:999px;font:700 .66rem/1.45 var(--ui,system-ui),sans-serif;font-style:normal;
    background:var(--gold);color:#241a2d;white-space:nowrap;
  }
}

/* ── the board ───────────────────────────────────────────────────────── */
.kol-board{
  display:grid;justify-items:center;gap:4px;margin:4px 0 2px;padding:6px 6px 5px;border-radius:14px;
  background:radial-gradient(120% 140% at 50% 0%,rgba(255,255,255,.08),transparent 60%),var(--kol-board);
  box-shadow:inset 0 0 0 2px rgba(255,198,92,.45),0 6px 16px -10px rgba(0,0,0,.8);
}
.kol-cat{margin:0;font-size:.74rem;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:var(--gold)}
.kol-tiles{--ts:30px;--tg:3px;width:100%;display:grid;justify-items:center;gap:var(--tg)}
.kol-row{display:flex;gap:var(--tg)}
.kol-sp{width:calc(var(--ts) * .45)}
.kol-t{
  width:var(--ts);height:calc(var(--ts) * 1.18);border-radius:calc(var(--ts) * .14);
  display:grid;place-items:center;font:800 calc(var(--ts) * .66)/1 var(--ui,system-ui),sans-serif;
  background:var(--kol-tile);color:var(--kol-tile-ink);
  box-shadow:inset 0 -2px 0 rgba(0,0,0,.14);
}
.kol-t.hid{background:linear-gradient(180deg,#e9f3ef,#c9ddd6);box-shadow:inset 0 -2px 0 rgba(0,0,0,.18),inset 0 0 0 1px rgba(13,59,55,.25)}
.kol-t.mark{background:transparent;box-shadow:none;color:var(--ivory);width:calc(var(--ts) * .45)}
.kol-t.flip{animation:kol-flip .55s cubic-bezier(.3,.7,.35,1.2) both}
@keyframes kol-flip{
  0%{transform:rotateX(0);background:#c9ddd6;color:transparent}
  45%{transform:rotateX(90deg);background:#c9ddd6;color:transparent}
  55%{transform:rotateX(90deg);background:var(--gold)}
  100%{transform:rotateX(0)}
}
.kol-used{margin:0;font-size:.72rem;color:rgba(246,239,224,.7);letter-spacing:.06em;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* ── the stage: the wheel or the keyboard ────────────────────────────── */
.kol-stage{position:relative;min-height:0;overflow:hidden}
/* both live on top of the stage, so that neither can push the rows of the screen */
.kol-wheel{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);display:grid;place-items:center}
.kol-wheel canvas{display:block;border-radius:50%;box-shadow:0 10px 26px -12px rgba(0,0,0,.85)}
.kol-pointer{
  position:absolute;left:50%;top:-4px;width:22px;height:26px;margin-left:-11px;
  background:var(--ivory);clip-path:polygon(0 0,100% 0,50% 100%);filter:drop-shadow(0 2px 2px rgba(0,0,0,.6));
}
.kol-hub{position:absolute;left:50%;top:50%;width:16%;height:16%;transform:translate(-50%,-50%);border-radius:50%;
  background:radial-gradient(circle at 35% 35%,#fff6d8,var(--gold) 60%,#a8741c);box-shadow:0 2px 6px rgba(0,0,0,.6)}
.kol-wheel.landed .kol-pointer{animation:kol-nod .35s ease-out}
@keyframes kol-nod{40%{transform:translateY(-4px)}}

.kol-keys{
  position:absolute;left:0;right:0;top:50%;transform:translateY(-50%);margin:0 auto;
  width:100%;max-width:470px;height:min(100%,236px);
  display:grid;grid-template-columns:repeat(9,minmax(0,1fr));grid-auto-rows:minmax(0,1fr);gap:5px;padding:3px 0;
}
.kol-keys[data-n="26"]{height:min(100%,180px)}
.kol-key{
  min-height:0;padding:0;border:0;border-radius:9px;font:800 1.05rem/1 var(--ui,system-ui),sans-serif;
  background:var(--kol-tile);color:var(--kol-tile-ink);box-shadow:inset 0 -3px 0 rgba(0,0,0,.18);cursor:pointer;
  -webkit-tap-highlight-color:transparent;
}
.kol-key.v{background:#ffe3a8}
.kol-key:active:not(:disabled){transform:scale(.94)}
.kol-key.off{opacity:.28;cursor:default}
.kol-key.used{opacity:.22;text-decoration:line-through;cursor:default;background:#777}
.kol-key.hn{box-shadow:inset 0 0 0 3px var(--gold),0 0 12px 2px rgba(255,198,92,.7);animation:kol-glow 1.2s ease-in-out infinite}
@keyframes kol-glow{50%{box-shadow:inset 0 0 0 3px var(--gold),0 0 3px 0 rgba(255,198,92,.4)}}
.kol-key:focus-visible{outline:2px solid var(--gold);outline-offset:2px}

/* ── the buttons ─────────────────────────────────────────────────────── */
.kol-bar{display:flex;justify-content:center;align-items:center;flex-wrap:wrap;gap:6px;min-height:52px;padding:4px 0 8px}
.kol-bar .btn{min-height:44px;flex:1 1 0;max-width:150px;padding:0 .6em;display:inline-grid;place-items:center;line-height:1.1}
.kol-bar .btn small{display:block;font-size:.68rem;opacity:.75;font-weight:600}
.kol-bar .kol-back{flex:0 0 auto}
.kol-info{margin:0;flex:1 1 100%;text-align:center;font-size:.86rem;color:var(--mist)}
.kol.keys .kol-bar{min-height:0;padding-bottom:6px}

/* ── typing the solution ─────────────────────────────────────────────── */
.kol-form{display:grid;gap:6px;padding:6px 0 4px}
.kol-input{
  width:100%;min-height:46px;padding:0 12px;border-radius:12px;border:2px solid var(--gold);
  background:var(--ivory);color:#241a2d;font:600 1.05rem var(--ui,system-ui),sans-serif;
}
.kol-formbtns{display:flex;gap:6px;justify-content:flex-end}
.kol-formbtns .btn{min-height:44px;min-width:6.5em}
.kol.typing{grid-template-rows:auto auto auto minmax(0,1fr);grid-template-areas:"top" "board" "form" "."}
.kol.typing .kol-plates,.kol.typing .kol-stage,.kol.typing .kol-bar{display:none}
.kol.typing .kol-say{display:none}

/* short screens: a little tighter */
.kol.short .kol-top{padding-top:3px;gap:1px}
.kol.short .kol-status{padding:.28em .8em;font-size:.86rem}
.kol.short .kol-say{font-size:.78rem}
.kol.short .kol-plate{min-height:38px}
.kol.short .kol-plate .ava{width:26px;height:26px}
.kol.tight .kol-cat,.kol.tight .kol-used{display:none}
.kol.tight .kol-say{display:none}

.kol-sum{margin:.2em auto .6em;padding:0 0 0 1.2em;max-width:30rem;font-size:.88rem;text-align:left;line-height:1.35}
.kol-sum li{margin:.2em 0}
.kol-sum-cat{font-size:.72rem;opacity:.7;text-transform:uppercase;letter-spacing:.05em}
.kol-sum-who{opacity:.8;white-space:nowrap}

@media (prefers-reduced-motion:reduce){
  .kol-t.flip,.kol-key.hn,.kol-wheel.landed .kol-pointer{animation:none}
}
