:root {
  --red: #c8102e;
  --dark-red: #8f0c21;
  --gold: #f5b800;
  --cream: #fff8e7;
  --green: #1f8a4c;
  --ink: #2b2118;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(180deg, var(--red), var(--dark-red));
  color: var(--ink);
  font-size: 20px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior-y: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.screen {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}
h1 { color: var(--cream); text-align: center; font-size: 2rem; margin: 12px 0; }
.lead { color: var(--cream); text-align: center; }
.label { color: var(--cream); font-weight: bold; margin: 12px 0 6px; }
label { color: var(--cream); font-weight: bold; display: block; margin-bottom: 6px; }
.error { color: var(--gold); font-weight: bold; min-height: 1.4em; text-align: center; }

input[type=text] {
  -webkit-user-select: text;
  user-select: text;
  width: 100%;
  font-size: 1.4rem;
  padding: 14px;
  border: 4px solid var(--gold);
  border-radius: 14px;
  text-transform: uppercase;
  text-align: center;
}

button {
  min-height: 48px;
  font: inherit;
  font-weight: bold;
  cursor: pointer;
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  background: var(--gold);
  color: var(--ink);
  box-shadow: 0 4px 0 #b88a00;
}
button:active { transform: translateY(3px); box-shadow: 0 1px 0 #b88a00; }
button:disabled { opacity: 0.5; cursor: default; }

.pieten { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.piet { padding: 14px 6px; background: var(--cream); font-size: 1rem; box-shadow: 0 4px 0 #cbbf9d; }
.piet .icon { display: block; font-size: 2.6rem; }
.piet.taken { opacity: 0.45; }

.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.me { color: var(--cream); font-weight: bold; font-size: 1.2rem; }
.mates { display: flex; gap: 8px; }
.mate { background: rgba(255, 248, 231, 0.18); color: var(--cream); border-radius: 12px; padding: 6px 10px; font-size: 0.85rem; text-align: center; }
.mate.off { opacity: 0.5; }

.letter-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; min-height: 64px; }
.letter-slot {
  width: 48px; height: 58px; border-radius: 10px;
  background: rgba(255, 248, 231, 0.2);
  border: 3px dashed var(--gold);
  color: var(--ink); font-size: 1.9rem; font-weight: bold;
  display: flex; align-items: center; justify-content: center;
}
.letter-slot.filled { background: var(--cream); border-style: solid; animation: pop 0.4s; }
@keyframes pop { 0% { transform: scale(0.3) rotate(-15deg); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }

.card { background: var(--cream); border-radius: 18px; padding: 16px; margin: 14px 0; box-shadow: 0 6px 0 rgba(0,0,0,0.2); }
.card h2 { margin: 0 0 6px; font-size: 1.3rem; color: var(--dark-red); }
.card.locked { opacity: 0.6; text-align: center; }
.card.done { background: #e4f6ea; }
.pieces { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; font-size: 3.4rem; margin: 8px 0; line-height: 1.1; }
.pieces .op { font-weight: bold; color: var(--dark-red); }
.pieces .txt { font-weight: bold; font-size: 3rem; color: var(--ink); }

.answer-row { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.answer-slot {
  width: 44px; height: 54px; border-bottom: 5px solid var(--dark-red); background: #fff;
  border-radius: 8px 8px 0 0; font-size: 1.8rem; font-weight: bold;
  display: flex; align-items: center; justify-content: center;
}
.answer-row.shake { animation: shake 0.4s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }

.board { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 10px; }
.board button { padding: 10px 0; min-height: 52px; font-size: 1.2rem; }
.board .wide { grid-column: span 2; background: #e3d7b6; box-shadow: 0 4px 0 #bdb08c; }
.actions { display: flex; gap: 8px; margin-top: 10px; }
.actions .go { flex: 1; background: var(--green); color: #fff; box-shadow: 0 4px 0 #14653a; }
.hint { background: #fff; border: 2px dashed var(--gold); border-radius: 12px; padding: 8px; margin-top: 8px; font-size: 0.95rem; }
.msg { min-height: 1.4em; text-align: center; font-weight: bold; margin: 6px 0 0; }
.msg.bad { color: var(--dark-red); }
.msg.good { color: var(--green); }

.status { position: fixed; top: 0; left: 0; right: 0; background: var(--gold); text-align: center; padding: 6px; font-weight: bold; z-index: 10; }

.win-word { display: flex; justify-content: center; gap: 8px; margin: 16px 0; flex-wrap: wrap; }
.win-word span { width: 56px; height: 72px; background: var(--cream); border-radius: 12px; font-size: 2.6rem; font-weight: bold; display: flex; align-items: center; justify-content: center; border: 4px solid var(--gold); animation: pop 0.6s backwards; }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 20; }

.small { color: var(--cream); font-size: 0.85rem; text-align: center; opacity: 0.85; margin: 6px 0; }
.count-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.count-row button { font-size: 1.6rem; background: var(--cream); box-shadow: 0 4px 0 #cbbf9d; }
.count-row button.on { background: var(--gold); outline: 4px solid var(--cream); }

.nut-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 4px; font-size: 1.3rem; }
.nut { opacity: 0.3; filter: grayscale(1); transition: all 0.3s; }
.nut.on { opacity: 1; filter: none; }
.nut.gap { margin-right: 12px; }
#nutCount { font-weight: normal; opacity: 0.85; }

.toast { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); max-width: 616px; margin: 0 auto; background: var(--cream); color: var(--ink); border: 4px solid var(--gold); border-radius: 16px; padding: 12px; text-align: center; font-weight: bold; z-index: 15; animation: pop 0.4s; }

.card.team { background: #fff2c2; border: 4px solid var(--gold); }
.card .badge { display: inline-block; background: var(--green); color: #fff; border-radius: 10px; padding: 2px 10px; font-size: 0.8rem; margin-bottom: 6px; }
.clue { background: #fff; border-left: 6px solid var(--green); border-radius: 8px; padding: 8px 10px; margin: 6px 0; font-size: 1rem; }
.holders { font-size: 0.95rem; margin: 6px 0; }
.card.wait { text-align: center; }
.dots { display: flex; gap: 6px; justify-content: center; margin: 4px 0 8px; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: #e3d7b6; }
.dot.on { background: var(--green); }

/* sleepbare letters */
.slots { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.slot { width: 48px; height: 58px; border-radius: 10px; background: #fff; border: 3px dashed var(--dark-red); display: flex; align-items: center; justify-content: center; font-size: 1.8rem; font-weight: bold; }
.slot.over { background: #ffe9a8; }
.tray { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; min-height: 64px; padding: 8px; background: rgba(0,0,0,0.06); border-radius: 12px; }
.tile { width: 52px; height: 58px; border-radius: 10px; background: var(--gold); box-shadow: 0 4px 0 #b88a00; font-size: 1.8rem; font-weight: bold; display: flex; align-items: center; justify-content: center; touch-action: none; cursor: grab; }
.tile.ghost { position: fixed; z-index: 30; pointer-events: none; transform: translate(-50%, -50%) scale(1.15); box-shadow: 0 10px 18px rgba(0,0,0,0.35); }
.tile.lifted { opacity: 0.3; }
.slot .tile { box-shadow: none; width: 100%; height: 100%; border-radius: 7px; }

@media (max-width: 380px) {
  body { font-size: 18px; }
  .answer-slot, .slot { width: 40px; height: 50px; }
  .tile { width: 46px; height: 52px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .pieces { font-size: 2.4rem; }
}

.restart { text-align: center; margin: 28px 0 40px; }
.hold { position: relative; overflow: hidden; background: rgba(255, 248, 231, 0.2); color: var(--cream); box-shadow: none; font-size: 0.9rem; -webkit-user-select: none; user-select: none; touch-action: none; }
.hold::after { content: ""; position: absolute; inset: 0; width: 0; background: var(--gold); opacity: 0.6; z-index: 0; }
.hold.holding::after { width: 100%; transition: width 3s linear; }
.hold:active { transform: none; }
