* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow-x: clip; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  background: linear-gradient(160deg, #1a1b3a 0%, #2d1b4e 50%, #4a1942 100%);
  color: #fff;
  min-height: 100dvh;
  overscroll-behavior: none;
}
#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; padding: 16px; }
.screen { display: none; animation: fade .25s ease; }
.screen.active { display: block; }
.hidden { display: none !important; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

.card {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 24px;
  padding: 28px 22px;
  margin-top: 4dvh;
  backdrop-filter: blur(8px);
  text-align: center;
}
h1 { font-size: 2rem; margin: 0 0 6px; }
h2 { font-size: 1.7rem; margin: 6px 0; }
.sub { opacity: .75; margin: 0 0 18px; line-height: 1.45; }
.big-emoji { font-size: 3.4rem; }

.names { display: flex; gap: 12px; margin-bottom: 18px; }
.names label { flex: 1; text-align: left; font-size: .85rem; opacity: .9; display: flex; flex-direction: column; gap: 6px; }
.names input {
  font-size: 1.05rem; padding: 12px; border-radius: 14px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.1); color: #fff; width: 100%; min-width: 0;
}

.opt-group { margin-bottom: 16px; text-align: left; }
.opt-label { font-size: .85rem; opacity: .7; display: block; margin-bottom: 8px; }
.pills { display: flex; gap: 8px; }
.pills button {
  flex: 1; padding: 12px 0; border-radius: 14px; font-size: 1rem; font-weight: 600;
  border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.07); color: #fff;
}
.pills button.sel { background: #7c5cff; border-color: #7c5cff; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check {
  padding: 10px 14px; border-radius: 999px; font-size: .92rem; cursor: pointer;
  border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.06); user-select: none;
}
.check.sel { background: rgba(124,92,255,.35); border-color: #7c5cff; }
.check input { display: none; }

button.big {
  width: 100%; padding: 16px; font-size: 1.1rem; font-weight: 700; border: none; border-radius: 16px;
  margin-top: 10px; cursor: pointer; color: #fff;
}
button.primary { background: linear-gradient(135deg, #7c5cff, #b04dff); box-shadow: 0 6px 20px rgba(124,92,255,.4); }
button.primary:active { transform: scale(.98); }
button.ghost { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); }

.pass { opacity: .7; margin: 0; }
.warn { opacity: .8; margin: 4px 0 20px; }
.word-card {
  background: rgba(255,255,255,.12); border-radius: 20px; padding: 26px 16px; margin-bottom: 8px;
}
.word { font-size: 2.6rem; font-weight: 800; margin-top: 10px; }
.cat-tag {
  display: inline-block; font-size: .8rem; background: rgba(124,92,255,.4); border: 1px solid #7c5cff;
  padding: 4px 12px; border-radius: 999px;
}

/* draw screen */
#screen-draw.active { display: flex; flex-direction: column; height: calc(100dvh - 32px); }
#draw-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 600; }
#timer-wrap {
  flex: 1; position: relative; height: 30px; background: rgba(255,255,255,.12); border-radius: 999px; overflow: hidden;
}
#timer-bar { height: 100%; width: 100%; background: linear-gradient(90deg, #38d39f, #7c5cff); transition: width .2s linear; }
#timer-bar.low { background: linear-gradient(90deg, #e53e3e, #dd6b20); }
#timer-num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .95rem; text-shadow: 0 1px 3px rgba(0,0,0,.5);
}
#secret-word { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 10px 0; }
#draw-word { font-size: 1.5rem; font-weight: 800; }
#canvas-wrap {
  flex: 1; min-height: 220px; border-radius: 20px; overflow: hidden;
  border: 1px solid rgba(255,255,255,.2); background: #fff; touch-action: none;
}
#canvas { display: block; touch-action: none; }
#tools { display: flex; align-items: center; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
#colors { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); cursor: pointer; padding: 0;
}
.swatch.sel { border-color: #fff; box-shadow: 0 0 0 2px #7c5cff; }
.swatch.eraser { border-style: dashed; }
#sizes { display: flex; gap: 4px; }
#sizes button {
  width: 38px; height: 38px; border-radius: 12px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.08); color: #fff; font-size: 1.2rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
#sizes button[data-s="4"] { font-size: .8rem; }
#sizes button[data-s="16"] { font-size: 1.7rem; }
#sizes button.sel { background: #7c5cff; border-color: #7c5cff; }
#tools > button:not(.swatch) {
  width: 44px; height: 44px; border-radius: 14px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.08); font-size: 1.2rem; cursor: pointer;
}
#draw-actions { display: flex; gap: 10px; }
#draw-actions .big { margin-top: 0; }
#btn-gotit { flex: 2; }
#btn-skip { flex: 1; }

.final-scores { margin: 6px 0 12px; }
.frow {
  display: flex; justify-content: space-between; font-size: 1.2rem; padding: 12px 18px;
  background: rgba(255,255,255,.08); border-radius: 14px; margin-bottom: 8px;
}
.frow b { font-size: 1.4rem; }

/* online multiplayer */
.btn-sub { display: block; font-size: .8rem; font-weight: 400; opacity: .75; margin-top: 4px; }
#btn-mode-solo { margin-bottom: 4px; }
.joinrow { display: flex; gap: 10px; margin-top: 10px; }
.joinrow input {
  flex: 1; min-width: 0; font-size: 1.3rem; font-weight: 800; letter-spacing: .3em; text-align: center;
  text-transform: uppercase; padding: 14px 8px; border-radius: 16px;
  border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.1); color: #fff;
}
.joinrow .big { width: auto; flex: 1; margin-top: 0; }
.err { color: #ff9d9d; font-size: .9rem; margin: 10px 0 0; }
#room-code {
  font-size: 3rem; font-weight: 800; letter-spacing: .35em; text-align: center;
  background: rgba(124,92,255,.25); border: 1px dashed #7c5cff; border-radius: 18px;
  padding: 14px 0 14px .35em; margin: 6px 0 4px;
}
.lobby-players { margin: 14px 0; }
.lobby-player {
  font-size: 1.1rem; padding: 10px 16px; background: rgba(255,255,255,.08);
  border-radius: 14px; margin-bottom: 8px;
}
#btn-online-start:disabled { opacity: .5; }
#guess-feed {
  max-height: 110px; overflow-y: auto; margin: 8px 0; display: flex; flex-direction: column; gap: 4px;
}
.guess {
  font-size: .9rem; background: rgba(255,255,255,.08); border-radius: 10px; padding: 6px 12px;
}
.guess.correct { background: rgba(56,211,159,.3); border: 1px solid #38d39f; font-weight: 700; }
#guesser-bar { display: flex; gap: 8px; margin: 4px 0 8px; }
#guesser-bar.hidden { display: none; }
#guess-input {
  flex: 1; min-width: 0; font-size: 1rem; padding: 14px; border-radius: 14px;
  border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.1); color: #fff;
}
#btn-guess {
  padding: 0 22px; border: none; border-radius: 14px; font-size: 1rem; font-weight: 700;
  color: #fff; background: linear-gradient(135deg, #7c5cff, #b04dff); cursor: pointer;
}

/* ---- small-phone polish ---- */
#screen-draw.active { height: calc(100vh - 32px); height: calc(100dvh - 32px); }
@media (max-width: 480px) {
  #app { padding: 12px; }
  .card { padding: 22px 16px; border-radius: 20px; }
  h1 { font-size: 1.65rem; }

  /* draw screen: keep the header compact */
  #draw-top { font-size: .82rem; gap: 8px; }
  #draw-scores { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34vw; }
  #secret-word { margin: 8px 0; }
  #draw-word { font-size: 1.3rem; }

  /* tools: one tidy scrollable row instead of a wrapped mess */
  #tools { flex-wrap: nowrap; gap: 6px; margin: 8px 0; }
  #colors { flex-wrap: nowrap; overflow-x: auto; min-width: 0; padding: 2px; scrollbar-width: none; }
  #colors::-webkit-scrollbar { display: none; }
  .swatch { width: 30px; height: 30px; flex: 0 0 auto; }
  #sizes { flex: 0 0 auto; }
  #sizes button { width: 34px; height: 34px; flex: 0 0 auto; }
  #tools > button:not(.swatch) { width: 40px; height: 40px; flex: 0 0 auto; font-size: 1.05rem; border-radius: 12px; }

  /* guesser UI stays compact so the canvas keeps its space */
  #guess-feed { max-height: 76px; margin: 6px 0; }
  #guesser-bar { margin: 2px 0 6px; }

  /* lobby + misc */
  #room-code { font-size: 2.3rem; }
  .joinrow input { padding-left: calc(.3em + 8px); }
  .word { font-size: 2.2rem; }
  button.big { padding: 15px; }
}

/* Chinese pack: English meaning hints */
.reveal-en { font-size: 1.15rem; opacity: .85; margin-top: 8px; }
#draw-en { font-size: .95rem; opacity: .8; font-style: italic; }
.lobby-packs { font-size: .9rem; opacity: .8; margin: 2px 0 10px; }
.hint-display {
  font-size: 1.35rem; font-weight: 800; letter-spacing: .12em; text-align: center;
  margin: 2px 0 6px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #ffd97c;
}
