:root{
  --paper: #FBF6EC;
  --paper-dark: #F1E9D8;
  --ink: #1F2547;
  --coral: #FF5A5F;
  --coral-dark: #E14448;
  --teal: #17A398;
  --teal-dark: #0E8177;
  --yellow: #FFC947;
  --graphite: #6B7280;
  --line: rgba(31,37,71,0.12);
  --shadow: 0 10px 30px rgba(31,37,71,0.15);
}
*{box-sizing:border-box;}
html,body{height:100%;}
body{
  margin:0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color:var(--ink);
  background:
    radial-gradient(circle at 15% 10%, rgba(255,90,95,0.10), transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(23,163,152,0.12), transparent 45%),
    var(--paper);
  min-height:100vh;
  display:flex;
  flex-direction:column;
  align-items:center;
  padding: 18px;
}
h1,h2,h3, .display{ font-family: "Baloo 2", system-ui, sans-serif; font-weight:800; }
.screen{ display:none; width:100%; max-width:560px; }
.screen.active{ display:block; }
.screen.wide{ max-width:760px; }

.brand{
  text-align:center; margin-bottom:22px;
}
.brand .display{ font-size:2.4rem; color:var(--ink); margin:0; letter-spacing:-0.5px; }
.brand .display span{ color:var(--coral); }
.brand p{ margin:4px 0 0; color:var(--graphite); font-size:0.95rem; }

.card{
  background:var(--paper);
  border:2.5px solid var(--ink);
  border-radius:18px;
  padding:26px;
  box-shadow: var(--shadow);
  position:relative;
}
.card::before{
  content:"";
  position:absolute; inset:6px;
  border:1.5px dashed var(--line);
  border-radius:12px;
  pointer-events:none;
}
.tilt{ transform: rotate(-1.1deg); }
.tilt:nth-of-type(even){ transform: rotate(1.1deg); }

label{ display:block; font-weight:700; font-size:0.85rem; margin: 14px 0 6px; color:var(--graphite); }
label:first-of-type{ margin-top:0; }
input[type=text], select{
  width:100%;
  font-family: inherit;
  font-size:1.05rem;
  padding:12px 14px;
  border-radius:10px;
  border:2px solid var(--ink);
  background:#fff;
  color:var(--ink);
}
input[type=text]:focus, select:focus{ outline:3px solid var(--yellow); outline-offset:1px; }

.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  font-family:"Baloo 2", system-ui, sans-serif;
  font-weight:700; font-size:1.05rem;
  padding:13px 22px;
  border-radius:12px;
  border:2.5px solid var(--ink);
  cursor:pointer;
  background:var(--yellow);
  color:var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform .08s ease, box-shadow .08s ease;
  width:100%;
  margin-top:16px;
}
.btn:active{ transform: translate(3px,3px); box-shadow: 0 0 0 var(--ink); }
.btn.coral{ background:var(--coral); color:#fff; }
.btn.teal{ background:var(--teal); color:#fff; }
.btn.ghost{ background:transparent; box-shadow:none; }
.btn.small{ width:auto; padding:8px 14px; font-size:0.85rem; margin-top:0; }
.btn:disabled{ opacity:0.45; cursor:not-allowed; box-shadow:none; transform:none; }
.row{ display:flex; gap:10px; }
.row .btn{ margin-top:0; }

.divider{ display:flex; align-items:center; gap:10px; color:var(--graphite); font-size:0.8rem; margin:18px 0; }
.divider::before, .divider::after{ content:""; flex:1; height:1px; background:var(--line); }

.roomcode-badge{
  display:inline-block; font-family:"Baloo 2",sans-serif; font-weight:800; font-size:1.5rem;
  letter-spacing:4px; background:var(--ink); color:var(--yellow); padding:8px 16px; border-radius:10px;
}

.player-list{ list-style:none; margin:12px 0; padding:0; display:flex; flex-direction:column; gap:8px; }
.player-list li{
  display:flex; justify-content:space-between; align-items:center;
  background:#fff; border:2px solid var(--line); border-radius:10px; padding:8px 12px; font-weight:600;
}
.player-list .score{ color:var(--teal-dark); font-family:"Baloo 2",sans-serif; }
.player-list .host-tag{ font-size:0.7rem; background:var(--coral); color:#fff; padding:2px 6px; border-radius:6px; margin-left:6px; }

.checkline{ display:flex; align-items:center; gap:8px; margin-top:14px; font-weight:600; font-size:0.9rem; }

/* ---- Game screen ---- */
.topbar{ display:flex; justify-content:space-between; align-items:center; margin-bottom:12px; gap:10px; flex-wrap:wrap; }
.pill{ background:#fff; border:2px solid var(--ink); border-radius:999px; padding:6px 14px; font-weight:700; font-size:0.85rem; }
.timer-pill{ background:var(--ink); color:var(--yellow); }
.timer-pill.low{ background:var(--coral); color:#fff; }

.wordcard{
  background:var(--yellow);
  border:2.5px solid var(--ink);
  border-radius:14px;
  padding:14px 18px;
  text-align:center;
  box-shadow: var(--shadow);
  margin-bottom:14px;
  transform: rotate(-0.6deg);
}
.wordcard .eyebrow{ font-size:0.72rem; text-transform:uppercase; letter-spacing:1.5px; color:var(--ink); opacity:0.65; font-weight:700;}
.wordcard .word{ font-family:"Baloo 2",sans-serif; font-weight:800; font-size:1.6rem; margin-top:4px; word-break:break-word; }

.canvas-wrap{
  background:repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(31,37,71,0.05) 28px), #fff;
  border:2.5px solid var(--ink);
  border-radius:14px;
  overflow:hidden;
  box-shadow: var(--shadow);
  touch-action:none;
}
canvas{ display:block; width:100%; height:auto; touch-action:none; cursor:crosshair; }

.tools{ display:flex; align-items:center; gap:10px; margin:10px 0; flex-wrap:wrap; }
.swatch{ width:28px; height:28px; border-radius:50%; border:2.5px solid var(--ink); cursor:pointer; }
.swatch.active{ outline:3px solid var(--yellow); outline-offset:2px; }

.guess-row{ display:flex; gap:8px; margin-top:10px; }
.guess-row input{ flex:1; }
.guess-log{ max-height:150px; overflow-y:auto; margin-top:10px; display:flex; flex-direction:column; gap:5px; }
.guess-item{ font-size:0.9rem; background:#fff; border:1.5px solid var(--line); border-radius:8px; padding:6px 10px; }
.guess-item.correct{ background: #e6f7f4; border-color:var(--teal); font-weight:700; }

.modal-overlay{
  position:fixed; inset:0; background:rgba(31,37,71,0.55);
  display:flex; align-items:center; justify-content:center; padding:20px; z-index:50;
}
.modal-overlay.hidden{ display:none; }
.forfeit-card{ background:var(--coral); color:#fff; border:3px solid var(--ink); border-radius:18px; padding:26px; max-width:420px; text-align:center; box-shadow:var(--shadow); transform:rotate(-1.5deg); }
.forfeit-card .tag{ font-family:"Baloo 2",sans-serif; font-weight:800; font-size:1.8rem; }
.forfeit-card p{ font-size:1.15rem; font-weight:600; margin:14px 0 0; }

.leaderboard{ list-style:none; padding:0; margin:16px 0; }
.leaderboard li{ display:flex; justify-content:space-between; align-items:center; background:#fff; border:2px solid var(--ink); border-radius:10px; padding:10px 14px; margin-bottom:8px; font-weight:700; }
.leaderboard li.winner{ background:var(--yellow); }
.cheer{ font-family:"Baloo 2",sans-serif; font-weight:800; font-size:1.25rem; margin:4px 0 0; }

.config-warning{
  background:#fff3cd; border:2px solid #e0a800; color:#664d03; padding:12px 14px; border-radius:10px;
  font-size:0.85rem; margin-bottom:16px; display:none;
}
.config-warning.show{ display:block; }
.footnote{ text-align:center; color:var(--graphite); font-size:0.78rem; margin-top:18px; }
.center{ text-align:center; }
.muted{ color:var(--graphite); font-size:0.9rem; }
@media (prefers-reduced-motion: reduce){ .tilt, .wordcard, .forfeit-card{ transform:none !important; } }

/* ---- Site navigation (shared by the party game and ALGO-GAMES) ---- */
.site-nav{ display:flex; justify-content:center; gap:8px; flex-wrap:wrap; margin-top:12px; }
.site-nav a{
  font-family:"Baloo 2", system-ui, sans-serif; font-weight:700; font-size:0.9rem; text-decoration:none;
  color:var(--ink); background:#fff; border:2px solid var(--ink); border-radius:999px; padding:6px 14px;
  box-shadow:2px 2px 0 var(--ink);
}
.site-nav a[aria-current="page"]{ background:var(--ink); color:var(--yellow); }
.site-nav a:focus-visible{ outline:3px solid var(--yellow); outline-offset:2px; }
