/* Čtyři v řadě: status and announcement on top, the two players' plates, the
   board in the room that is left, the buttons at the bottom. On a wide screen
   the board stands on the left and everything else beside it.
   The board is a blue panel with round holes; the discs lie behind it, so a
   falling disc passes behind the panel as in the real thing. Above the board
   runs the lane where my disc waits before it falls. */
.ctyri{
  --ctyri-red:#d8343f;--ctyri-red-hi:#ff8086;--ctyri-red-lo:#8f1823;
  --ctyri-yel:#f2b630;--ctyri-yel-hi:#ffe48a;--ctyri-yel-lo:#b97a0c;
  --ctyri-panel:#2559b4;--ctyri-panel-lo:#173c80;
  --ctyri-me:#58b947;--ctyri-foe:#e2404c;--ctyri-hint:#ffc65c; /* the hint's own gold: the skin's --gold may be green */
  position:absolute;inset:0;
  display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto auto minmax(0,1fr) auto;
  grid-template-areas:"top" "plates" "main" "bar";
  overflow:hidden;
}
.ctyri-top{grid-area:top;display:grid;justify-items:center;gap:2px;padding:6px 10px 2px}
.ctyri-status{padding:.4em .9em;font-size:.93rem}
.ctyri-say{
  margin:0;min-height:1.3em;max-width:24rem;
  font-size:.88rem;line-height:1.3;text-align:center;color:var(--mist);
}
.ctyri-say.big{color:var(--ivory);font-weight:600}

/* ── plates ──────────────────────────────────────────────────────────── */
.ctyri-plates{grid-area:plates;display:flex;justify-content:center;gap:8px;padding:4px 8px}
.ctyri-plate{
  display:flex;align-items:center;gap:8px;
  flex:0 1 220px;min-width:0;min-height:46px;padding:4px 8px 4px 5px;
  border:1.5px solid var(--line);border-radius:999px;
  background:rgba(13,18,10,.3);
  transition:border-color .2s,background-color .2s;
}
.ctyri-plate .ava{width:34px;height:34px;font-size:1rem;flex:none}
.ctyri-who{display:grid;line-height:1.15;min-width:0;flex:1}
.ctyri-who .nm{font-weight:600;font-size:.9rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ctyri-who .sub{font-size:.72rem;color:var(--mist);white-space:nowrap}
.ctyri-plate.turn{border-color:var(--gold);background:rgba(118,176,67,.13)}
.ctyri-plate.turn .ava{box-shadow:0 0 0 2.5px var(--gold)}
.ctyri-plate.best .ctyri-chip{box-shadow:0 0 0 2.5px var(--gold)}
.ctyri-pips{display:flex;gap:4px;margin-top:3px}
.ctyri-pips i{width:8px;height:8px;border-radius:50%;border:1.5px solid var(--mist)}
.ctyri-pips i.on{background:var(--gold);border-color:var(--gold)}

/* a disc: red or yellow, a little domed */
.ctyri-chip,.ctyri-disc{border-radius:50%}
.ctyri-chip{flex:none;width:28px;height:28px}
.ctyri-chip.red,.ctyri-disc.red,.ctyri-ghost.red{--d:var(--ctyri-red);--d-hi:var(--ctyri-red-hi);--d-lo:var(--ctyri-red-lo)}
.ctyri-chip.yel,.ctyri-disc.yel,.ctyri-ghost.yel{--d:var(--ctyri-yel);--d-hi:var(--ctyri-yel-hi);--d-lo:var(--ctyri-yel-lo)}
.ctyri-chip,.ctyri-disc{
  background:radial-gradient(circle at 36% 30%,var(--d-hi),var(--d) 42%,var(--d-lo) 100%);
  box-shadow:inset 0 0 0 calc(var(--cell,28px)*.07) rgba(0,0,0,.14),inset 0 -2px 3px rgba(0,0,0,.25);
}

/* ── the board ───────────────────────────────────────────────────────── */
.ctyri-main{grid-area:main;display:grid;place-items:center;min-width:0;min-height:0;overflow:hidden}
.ctyri-stage{
  --cell:44px;--cols:7;--rows:6;--lane:calc(var(--cell)*.85);
  position:relative;
  width:calc(var(--cols)*var(--cell));height:calc(var(--rows)*var(--cell) + var(--lane));
}
.ctyri-lane{position:absolute;left:0;right:0;top:0;height:var(--lane)}
.ctyri-board{
  position:absolute;left:0;top:var(--lane);
  width:calc(var(--cols)*var(--cell));height:calc(var(--rows)*var(--cell));
}
.ctyri-discs,.ctyri-marks,.ctyri-frame{position:absolute;inset:0;pointer-events:none}
.ctyri-discs{z-index:1}
.ctyri-frame{
  z-index:2;border-radius:calc(var(--cell)*.16);
  background:
    radial-gradient(circle,transparent calc(var(--cell)*.41),rgba(0,0,0,.3) calc(var(--cell)*.41 + .5px),rgba(0,0,0,0) calc(var(--cell)*.47)) 0 0/var(--cell) var(--cell),
    radial-gradient(circle,transparent calc(var(--cell)*.41),var(--ctyri-panel) calc(var(--cell)*.41 + .5px)) 0 0/var(--cell) var(--cell);
  box-shadow:0 0 0 calc(var(--cell)*.08) var(--ctyri-panel),0 0 0 calc(var(--cell)*.08 + 1.5px) var(--ctyri-panel-lo),0 14px 28px -12px rgba(0,0,0,.85);
}
/* the holes show the cloth darkened */
.ctyri-board::before{content:"";position:absolute;inset:0;z-index:0;border-radius:calc(var(--cell)*.16);background:rgba(8,12,30,.45)}
.ctyri-marks{z-index:3}

.ctyri-disc{
  position:absolute;
  left:calc(var(--c)*var(--cell) + var(--cell)*.09);top:calc(var(--r)*var(--cell) + var(--cell)*.09);
  width:calc(var(--cell)*.82);height:calc(var(--cell)*.82);
}
.ctyri-disc.fall{animation:ctyri-fall .5s both}
@keyframes ctyri-fall{
  0%{transform:translateY(calc(var(--drop)*var(--cell)*-1));animation-timing-function:cubic-bezier(.45,0,.9,.6)}
  72%{transform:translateY(0);animation-timing-function:ease-out}
  84%{transform:translateY(calc(var(--cell)*-.13));animation-timing-function:ease-in}
  100%{transform:translateY(0)}
}
/* the last disc: a small dot in the middle */
.ctyri-disc.last::after{
  content:"";position:absolute;left:50%;top:50%;width:18%;height:18%;margin:-9% 0 0 -9%;
  border-radius:50%;background:rgba(255,255,255,.7);box-shadow:0 0 0 1px rgba(0,0,0,.2);
}
/* a round over: the four glows, the rest steps back */
.ctyri-board.done .ctyri-disc{opacity:.5;transition:opacity .4s}
.ctyri-board.done .ctyri-disc.win{opacity:1}
.ctyri-ring.win{
  left:calc(var(--c)*var(--cell) + var(--cell)*.04);top:calc(var(--r)*var(--cell) + var(--cell)*.04);
  width:calc(var(--cell)*.92);height:calc(var(--cell)*.92);
  --ring:var(--gold);border-width:calc(var(--cell)*.08);
  box-shadow:0 0 calc(var(--cell)*.25) var(--gold),inset 0 0 calc(var(--cell)*.12) var(--gold);
  animation:ctyri-win 1.1s ease-in-out .5s infinite alternate;
}
@keyframes ctyri-win{to{box-shadow:0 0 calc(var(--cell)*.08) var(--gold),inset 0 0 calc(var(--cell)*.04) var(--gold)}}

/* where my disc would land, and the disc waiting in the lane */
.ctyri-ghost,.ctyri-ring{
  position:absolute;border-radius:50%;
  left:calc(var(--c)*var(--cell) + var(--cell)*.12);top:calc(var(--r)*var(--cell) + var(--cell)*.12);
  width:calc(var(--cell)*.76);height:calc(var(--cell)*.76);
}
.ctyri-ghost{border:calc(var(--cell)*.06) dashed var(--d);background:color-mix(in srgb,var(--d) 22%,transparent)}
.ctyri-lane .ctyri-disc.wait{
  top:calc(var(--lane) - var(--cell)*.86);opacity:.62;
  animation:ctyri-bob 1.4s ease-in-out infinite;
}
.ctyri-lane .ctyri-disc.wait.chosen{opacity:.92;box-shadow:inset 0 0 0 calc(var(--cell)*.07) rgba(0,0,0,.14),0 0 0 2px var(--ivory)}
@keyframes ctyri-bob{50%{transform:translateY(calc(var(--cell)*-.07))}}

/* what a hint marks (server/hints/ctyri.js, hint.mark): rings where a side would make four (filled: it can
   be done now), the cell where the advised disc lands, an arrow over its column, the next best columns
   numbered, crosses over the columns not to touch */
.ctyri-ring{border:calc(var(--cell)*.07) solid var(--ring);opacity:.95}
.ctyri-ring.me{--ring:var(--ctyri-me)}
.ctyri-ring.foe{--ring:var(--ctyri-foe)}
.ctyri-ring.now{background:color-mix(in srgb,var(--ring) 38%,transparent)}
.ctyri-ring.best{--ring:var(--ctyri-hint);border-width:calc(var(--cell)*.09);animation:ctyri-pulse 1.1s ease-in-out infinite}
@keyframes ctyri-pulse{50%{transform:scale(.88)}}
.ctyri-lane b{
  position:absolute;bottom:2px;left:calc(var(--c)*var(--cell));width:var(--cell);
  display:grid;place-items:center;font:800 calc(var(--cell)*.36)/1 var(--ui);pointer-events:none;
}
.ctyri-arrow{height:calc(var(--lane) - 4px)}
.ctyri-arrow::before{
  content:"";width:0;height:0;
  border-left:calc(var(--cell)*.2) solid transparent;border-right:calc(var(--cell)*.2) solid transparent;
  border-top:calc(var(--cell)*.26) solid var(--ctyri-hint);
  filter:drop-shadow(0 1px 1px rgba(0,0,0,.5));animation:ctyri-bob 1.1s ease-in-out infinite;
}
.ctyri-alt{height:calc(var(--lane) - 4px);color:var(--ctyri-hint);opacity:.75}
.ctyri-no{height:calc(var(--lane) - 4px);color:var(--ctyri-foe);text-shadow:0 1px 1px rgba(0,0,0,.5)}

/* the columns: what is tapped, over the whole height of lane and board */
.ctyri-cols{position:absolute;inset:0;z-index:4;display:grid;grid-template-columns:repeat(var(--cols),1fr)}
.ctyri-col{
  min-width:0;padding:0;border:0;border-radius:calc(var(--cell)*.2);background:transparent;
  -webkit-tap-highlight-color:transparent;cursor:pointer;
}
.ctyri-col:disabled{cursor:default}
.ctyri-col:focus-visible{outline:2px solid var(--ivory);outline-offset:-3px}
.ctyri-col.over{background:rgba(255,255,255,.07)}
.ctyri-col.sel{background:rgba(255,255,255,.13);box-shadow:inset 0 0 0 2px rgba(255,255,255,.35)}
.ctyri-col.full{cursor:not-allowed}
.ctyri-col.best{box-shadow:inset 0 0 0 2px color-mix(in srgb,var(--ctyri-hint) 70%,transparent)}
.ctyri-col.sel.best{box-shadow:inset 0 0 0 2px var(--ctyri-hint)}
.ctyri-col.shake{animation:shake .3s}

/* ── buttons ─────────────────────────────────────────────────────────── */
.ctyri-bar{grid-area:bar;display:flex;justify-content:center;align-items:center;gap:8px;padding:6px 10px 10px;min-height:62px}
.ctyri-bar .btn{min-height:46px;min-width:8em;padding:.4em 1.1em;font-size:.98rem;white-space:nowrap}

.ctyri-sum{margin:.2em 0 .6em;font-size:.9rem;opacity:.75;text-align:center}

/* ── a wide screen: the board on the left, the rest beside it ────────── */
.ctyri.wide{
  grid-template-columns:minmax(0,720px) clamp(190px,30%,280px);
  grid-template-rows:auto auto minmax(0,1fr) auto;
  grid-template-areas:"main top" "main plates" "main ." "main bar";
  justify-content:center;column-gap:8px;
}
.ctyri.wide .ctyri-top{padding-top:14px}
.ctyri.wide .ctyri-plates{flex-direction:column;align-items:stretch;padding:8px}
.ctyri.wide .ctyri-plate{flex:none}
.ctyri.wide .ctyri-bar{flex-direction:column-reverse;align-items:stretch;padding:8px 8px 14px}

/* a short screen: everything a little tighter */
@media (max-height:600px){
  .ctyri-top{padding-top:3px;gap:0}
  .ctyri-status{padding:.3em .8em;font-size:.86rem}
  .ctyri-say{font-size:.8rem}
  .ctyri-plates{padding:2px 6px;gap:6px}
  .ctyri-plate{min-height:38px;padding:2px 6px 2px 3px}
  .ctyri-plate .ava{width:28px;height:28px;font-size:.85rem}
  .ctyri-chip{width:22px;height:22px}
  .ctyri-bar{min-height:52px;padding:4px 8px 6px}
  .ctyri-bar .btn{min-height:44px;font-size:.92rem}
  .ctyri.wide .ctyri-top{padding-top:6px}
  .ctyri.wide .ctyri-plates{padding:4px 6px}
  .ctyri.wide .ctyri-bar{flex-direction:row;flex-wrap:wrap;padding:4px 6px 6px}
}
@media (prefers-reduced-motion:reduce){
  .ctyri-disc.fall,.ctyri-lane .ctyri-disc.wait,.ctyri-ring.best,.ctyri-arrow::before,.ctyri-ring.win{animation:none}
}
html.still .ctyri-disc.fall,html.still .ctyri-lane .ctyri-disc.wait,html.still .ctyri-ring.best,html.still .ctyri-arrow::before,html.still .ctyri-ring.win{animation:none}
