/* ============================================================================
   Kachelglueck — Anzeige. Wichtigster Grundsatz: die KACHELGROESSE WIRD EINMAL
   beim Start berechnet (--kgW/--kgH) und danach NIE mehr angefasst. Alle Kacheln
   sind absolut positioniert; das Abraeumen kann darum nichts umfliessen lassen.
   ============================================================================ */
*{box-sizing:border-box}
html,body{height:100%;margin:0}
body{
  background:radial-gradient(1000px 600px at 50% -10%,#3d2a20 0%,#2b1d16 55%,#1e140f 100%);
  color:#f6eeda;font-family:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  overflow:hidden;-webkit-tap-highlight-color:transparent;user-select:none
}
.kg-app{height:100%;display:flex;align-items:center;justify-content:center;padding:8px}
.kg-shell{position:relative;width:100%;max-width:1000px;height:100%;display:flex;flex-direction:column;gap:8px}

/* ---- Kopfzeile ---- */
.kg-top{display:flex;align-items:center;gap:8px;flex:0 0 auto}
.kg-brand{font-weight:800;letter-spacing:.04em;font-size:15px;line-height:1.1;margin-right:auto}
.kg-brand small{display:block;font-weight:600;font-size:10px;opacity:.6;letter-spacing:.12em;text-transform:uppercase}
.kg-icon{background:#4a3225;border:1px solid #6b4a35;color:#f6eeda;border-radius:9px;
  width:38px;height:38px;font-size:17px;cursor:pointer;line-height:1}
.kg-icon:hover{background:#5c3f2e}
.kg-icon.off{opacity:.42}
.kg-back{color:#e8c07a;text-decoration:none;font-size:14px;font-weight:600;padding:8px 10px;white-space:nowrap}
.kg-back:hover{color:#f6eeda}

/* ---- Zahlenleiste ---- */
.kg-hud{display:flex;gap:6px;flex:0 0 auto;flex-wrap:wrap}
.kg-stat{background:#3a2820;border:1px solid #55392a;border-radius:9px;padding:5px 11px;min-width:74px;text-align:center}
.kg-stat small{display:block;font-size:10px;opacity:.6;letter-spacing:.09em;text-transform:uppercase}
.kg-stat b{font-size:17px;font-variant-numeric:tabular-nums}

/* Ungewertet-Hinweis: muss auffallen, ohne das Weiterspielen zu stoeren */
.kg-unrated{background:#7a4a12;border:1px solid #c98b2a;color:#ffdc9a;border-radius:9px;
  padding:5px 12px;font-size:13px;font-weight:700;display:flex;align-items:center;letter-spacing:.02em}
.kg-unrated[hidden]{display:none}

/* ---- Brett ---- */
.kg-boardwrap{flex:1 1 auto;min-height:0;display:flex;align-items:center;justify-content:center}
.kg-board{position:relative;flex:0 0 auto}      /* Groesse setzt game.js einmalig */

.kg-tile{
  position:absolute;
  width:var(--kgW);height:var(--kgH);          /* EINMAL gesetzt, danach konstant */
  border-radius:calc(var(--kgW)*.14);
  background:linear-gradient(158deg,#fffaf0 0%,#f3e4c8 58%,#e2cda8 100%);
  border:1px solid #b99a6d;
  box-shadow:0 2px 0 #a8875c, 0 3px 5px rgba(0,0,0,.42);
  display:flex;align-items:center;justify-content:center;
  cursor:pointer;overflow:hidden;
  transition:transform .12s ease, box-shadow .12s ease, opacity .18s ease
}
.kg-tile svg{width:78%;height:78%;pointer-events:none;display:block}
.kg-tile.blocked{cursor:default;filter:brightness(.8) saturate(.72)}
.kg-tile.free:hover{transform:translateY(-2px);box-shadow:0 4px 0 #a8875c,0 7px 10px rgba(0,0,0,.45)}
.kg-tile.sel{
  background:linear-gradient(158deg,#fff6d8 0%,#ffe6a8 60%,#f2c14e 100%);
  border-color:#c1362f;box-shadow:0 0 0 3px #c1362f, 0 4px 8px rgba(0,0,0,.45);transform:translateY(-3px)
}
.kg-tile.hintpulse{animation:kgpulse .55s ease 2}
@keyframes kgpulse{0%,100%{box-shadow:0 2px 0 #a8875c,0 3px 5px rgba(0,0,0,.42)}
  50%{box-shadow:0 0 0 4px #7fb069,0 4px 10px rgba(0,0,0,.5)}}
.kg-tile.nope{animation:kgshake .3s ease}
@keyframes kgshake{0%,100%{transform:translateX(0)}25%{transform:translateX(-4px)}75%{transform:translateX(4px)}}
.kg-tile.gone{opacity:0;transform:scale(.6);pointer-events:none}

/* ---- Hinweiszeile ---- */
.kg-tip{flex:0 0 auto;margin:0;text-align:center;font-size:12px;opacity:.62;line-height:1.45}
.kg-tip b{opacity:.9}

/* ---- Überlagerungen ---- */
.kg-ov{position:absolute;inset:0;background:rgba(20,13,9,.9);backdrop-filter:blur(3px);
  display:flex;align-items:center;justify-content:center;z-index:9000;padding:14px}
.kg-ov[hidden]{display:none}
.kg-dlg{background:#3a2820;border:1px solid #6b4a35;border-radius:16px;padding:24px 26px;
  max-width:440px;width:100%;text-align:center;box-shadow:0 18px 50px rgba(0,0,0,.6)}
.kg-dlg h1{margin:0 0 2px;font-size:31px;color:#f2c14e;letter-spacing:.02em}
.kg-dlg h2{margin:0 0 10px;font-size:25px;color:#f2c14e}
.kg-sub{margin:0 0 14px;font-size:13px;font-style:italic;opacity:.6;letter-spacing:.05em}
.kg-dlg p{margin:0 0 12px;line-height:1.55;font-size:15px}
.kg-rules{text-align:left;margin:0 0 16px;padding-left:20px;font-size:13.5px;line-height:1.6;opacity:.86}
.kg-rules li{margin-bottom:5px}
.kg-small{font-size:13px;opacity:.72}
.kg-score{font-size:20px}
.kg-score b{color:#f2c14e;font-size:27px;font-variant-numeric:tabular-nums}
.kg-err{color:#ff9d94;font-size:13.5px;min-height:1.2em;margin:6px 0 0}
.kg-ok{color:#9fe0a8;font-size:15px;font-weight:600}
.kg-btn{background:#c1362f;color:#fff6e0;border:none;border-radius:10px;padding:13px 26px;
  font:inherit;font-size:16px;font-weight:700;cursor:pointer;margin-top:6px}
.kg-btn:hover{background:#d8443c}
.kg-btn[disabled]{opacity:.5;cursor:default}
.kg-btn-ghost{background:transparent;border:1px solid #6b4a35;color:#e8c07a;margin-top:10px;font-size:14px;padding:9px 18px}
.kg-btn-ghost:hover{background:#4a3225}
.kg-entry{display:flex;gap:8px;justify-content:center;margin:8px 0 0}
.kg-entry input{background:#2b1d16;border:1px solid #6b4a35;color:#f6eeda;border-radius:9px;
  padding:12px 14px;font:inherit;font-size:19px;width:120px;text-align:center;text-transform:uppercase;letter-spacing:.16em}
.kg-count{font-size:96px;font-weight:800;color:#f2c14e;text-shadow:0 6px 24px rgba(0,0,0,.6)}

@media (max-width:560px){
  .kg-brand{font-size:13px}
  .kg-stat{min-width:60px;padding:4px 8px}
  .kg-stat b{font-size:15px}
  .kg-tip{font-size:11px}
  .kg-dlg{padding:18px 16px}
  .kg-dlg h1{font-size:26px}
}
@media (max-height:520px){
  .kg-tip{display:none}
  .kg-hud{gap:4px}
}
