/* Icelandic kaffihús — CSS-only art in v1: warm wood, cream, chalkboard. */
:root {
  --wood-dark: #2b1d16;
  --wood: #45332a;
  --wood-light: #7a5c3e;
  --cream: #f3e9dc;
  --cream-dim: #b09a85;
  --amber: #e8a94e;
  --amber-shadow: #a4700f;
  --chalk-green: #2f4a3e;
  --chalk-line: #3d5c4e;
  --gold: #f7d9a8;
  --good: #81b29a;
  --bad: #e07a5f;
}

* { margin: 0; box-sizing: border-box; }
html, body { overflow: hidden; }
body {
  height: 100vh; height: 100svh;
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; flex-direction: column;
  font-family: -apple-system, system-ui, sans-serif;
  background: var(--wood-dark); color: var(--cream);
  touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}

header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px 4px;
}
#bord { font-weight: 800; font-size: 18px; color: var(--gold); }
#cups { font-size: 14px; letter-spacing: 1px; }
#bonus-chip {
  font: inherit; font-weight: 700; border: 0; border-radius: 999px;
  padding: 6px 12px; background: var(--wood); color: var(--cream);
  transition: transform 200ms;
}
#bonus-chip.pulse { transform: scale(1.25); }

main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#stage { transition: transform 250ms ease, opacity 250ms ease; }
#stage.out { transform: translateX(-60px); opacity: 0; }
#stage.in { transform: translateX(60px); opacity: 0; transition: none; }

/* chalkboard word board */
#slots {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  margin: 4px 12px; padding: 12px 8px;
  background: var(--chalk-green);
  border: 4px solid var(--wood-light); border-radius: 10px;
}
.word { display: flex; gap: 5px; }
.cell {
  width: 34px; height: 34px; border-radius: 7px;
  background: var(--chalk-line); display: grid; place-items: center;
  font-size: 20px; font-weight: 700; color: var(--gold);
  text-transform: uppercase;
}
.cell.hinted { color: var(--cream-dim); }
.cell.filled { background: var(--wood-light); color: var(--cream); }
.word.solved .cell { animation: pulse 400ms; }
@keyframes pulse {
  50% { transform: scale(1.15); }
}

#preview {
  text-align: center; height: 34px; line-height: 34px;
  font-size: 26px; font-weight: 700; letter-spacing: 3px;
  color: var(--gold); text-transform: uppercase;
}
#preview.bad { color: var(--bad); }
#preview.ok { color: var(--good); }

#scatter { position: relative; flex: 1; overflow: visible; min-height: 0; }
#trace { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
#trace polyline, #trace line { stroke: var(--amber); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }

/* sugar-cube letter tiles */
.tile {
  position: absolute; left: 0; top: 0;
  display: grid; place-items: center;
  background: var(--cream); color: var(--wood-dark);
  border-radius: 14px; font-weight: 800; text-transform: uppercase;
  box-shadow: 0 3px 0 var(--cream-dim);
  transition: transform 350ms cubic-bezier(.3, 1.3, .4, 1);
  will-change: transform;
}
.tile.sel { background: var(--amber); box-shadow: 0 3px 0 var(--amber-shadow); }
.tile.fly { z-index: 10; }

footer { display: flex; gap: 10px; padding: 8px 12px; align-items: center; justify-content: center; }
footer button {
  font: inherit; font-weight: 600; border: 0; border-radius: 999px;
  padding: 10px 18px; background: var(--wood); color: var(--cream);
}

#bonus-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(75vw, 300px);
  background: var(--wood); padding: 20px; z-index: 30;
  border-left: 4px solid var(--wood-light);
  overflow-y: auto;
}
#bonus-panel h2 { font-size: 16px; color: var(--gold); margin-bottom: 10px; }
#bonus-list { list-style: none; padding: 0; }
#bonus-list li { padding: 4px 0; text-transform: uppercase; font-weight: 600; }

dialog {
  border: 4px solid var(--wood-light); border-radius: 12px;
  background: var(--cream); color: var(--wood-dark);
  max-width: min(85vw, 420px); padding: 20px;
}
dialog::backdrop { background: rgba(43, 29, 22, .7); }
dialog h2 { margin-bottom: 8px; }
dialog h3 { margin: 12px 0 4px; font-size: 14px; }
dialog p { font-size: 13px; margin: 6px 0; }
dialog button { font: inherit; border: 0; border-radius: 999px; padding: 8px 16px; background: var(--wood); color: var(--cream); margin-top: 10px; }

/* a word flying out to the bonus chip */
#bonus-fly {
  position: fixed; z-index: 40; pointer-events: none;
  font-weight: 800; font-size: 22px; color: var(--good); text-transform: uppercase;
  transition: transform 500ms cubic-bezier(.5, 0, .8, .4), opacity 500ms;
  will-change: transform;
}
