/* Player (phone) screens */
body.player { min-height: 100dvh; overflow-x: hidden; }
#app { min-height: 100dvh; display: flex; flex-direction: column; }

.screen { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); text-align: center; }
.screen .mascot { width: 130px; height: 130px; }
.screen h1 { font-size: 2rem; line-height: 1.1; }
.screen h2 { font-size: 1.5rem; line-height: 1.15; }
.screen p { font-size: 1.1rem; }

.join-card { width: min(100%, 380px); padding: 22px 18px; display: flex; flex-direction: column; gap: 14px; }
.join-card .btn { width: 100%; font-size: 1.3rem; }
.code-input { letter-spacing: .25em; font-size: 2rem; }
.form-error { color: var(--bad); font-weight: 700; min-height: 1.4em; }
.title-pill { display: inline-block; background: var(--purple-soft); color: var(--purple-dark); font-weight: 800;
  padding: .25em .9em; border-radius: 999px; font-size: .95rem; }

.avatar-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.avatar-opt { appearance: none; -webkit-appearance: none; border: 3px solid transparent; background: var(--bg-2); border-radius: 16px;
  padding: 6px; cursor: pointer; min-width: 0; display: block; transition: transform .1s; color: inherit; }
.avatar-opt.on { border-color: var(--purple); background: var(--purple-soft); transform: scale(1.06); }

/* Top bar during the game */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px; background: #fff; border-bottom: 2px solid var(--line); font-weight: 800; }
.topbar .me { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar .me .animal { width: 34px; height: 34px; flex: none; }
.topbar .me span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .score { background: var(--ink); color: #fff; border-radius: 999px; padding: .15em .8em; white-space: nowrap; }
.topbar .qnum { color: var(--muted); white-space: nowrap; }

.big-avatar { width: 160px; height: 160px; }
.change-animal { font-size: .95rem; }

.countdown-num { font-size: 6rem; font-weight: 800; color: var(--purple); line-height: 1; }
.type-label { font-size: 1.2rem; font-weight: 800; background: #fff; border: 2px solid var(--line); padding: .3em 1em; border-radius: 999px; }

/* Question */
.q-wrap { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); }
.q-text { font-size: 1.2rem; font-weight: 700; text-align: center; padding: 4px 6px; line-height: 1.25; }
.timer-bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.timer-bar i { display: block; height: 100%; background: var(--purple); border-radius: 999px; transform-origin: left; }
.pick-hint { text-align: center; font-weight: 800; color: var(--purple-dark); }

.answers { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; min-height: 260px; }
.answers.two { grid-template-columns: 1fr; }
.ans {
  appearance: none; border: 0; cursor: pointer; border-radius: 20px; color: #fff;
  background: var(--c); box-shadow: 0 6px 0 var(--cd);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 8px; font-weight: 800; font-size: 1.1rem; line-height: 1.15; position: relative;
  transition: transform .08s, box-shadow .08s, opacity .2s;
}
.ans:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--cd); }
.ans .badge { width: 62px; height: 62px; background: #fff; border-radius: 50%; padding: 5px; flex: none; }
.answers.two .ans { flex-direction: row; justify-content: flex-start; gap: 14px; padding: 12px 18px; font-size: 1.4rem; }
.ans.sel { outline: 5px solid var(--ink); outline-offset: -5px; }
.ans.sel::after { content: '✓'; position: absolute; top: 8px; right: 12px; font-size: 1.5rem; }
.ans.dim { opacity: .35; }

.type-box { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.type-box .input { font-size: 1.6rem; }
.type-box .btn { font-size: 1.3rem; }

/* Result screens */
.result { color: #fff; }
.result.good { background: var(--good); }
.result.bad { background: var(--bad); }
.result.miss { background: var(--muted); }
.result.cloud { background: var(--purple); }
.result h1 { font-size: 2.6rem; }
.result .points { font-size: 2.2rem; font-weight: 800; background: rgba(255, 255, 255, .22); padding: .1em .8em; border-radius: 999px; }
.result .streak { font-weight: 800; font-size: 1.2rem; }
.result .answer-was { background: rgba(255, 255, 255, .2); border-radius: 16px; padding: .5em 1em; font-weight: 700; }
.result .mascot { width: 120px; height: 120px; }

.rank-big { font-size: 4.5rem; font-weight: 800; line-height: 1; color: var(--purple); }
.medal { font-size: 4rem; line-height: 1; }

.paused-overlay { position: fixed; inset: 0; background: rgba(61, 44, 78, .75); color: #fff; display: flex;
  flex-direction: column; align-items: center; justify-content: center; gap: 10px; z-index: 30; font-size: 2rem; font-weight: 800; }

.sound-btn { position: fixed; bottom: calc(12px + env(safe-area-inset-bottom)); right: 12px; z-index: 20; }

.modal { position: fixed; inset: 0; background: rgba(61, 44, 78, .5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 35; }
.modal .card { width: min(100%, 380px); padding: 18px; display: flex; flex-direction: column; gap: 12px; }

/* iPhone / iPad Safari: taps should always count as taps.
   No text selection, magnifier or callout menu on the game screens (text boxes still work),
   and no double-tap zoom on buttons. */
body.player { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-text-size-adjust: 100%; }
body.player input, body.player textarea { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
body.player button, body.player .ans, body.player .avatar-opt { touch-action: manipulation; }
.form-error:empty { min-height: 0; margin: -7px 0; }
body.player[data-bg=good] { background: var(--good); }
body.player[data-bg=bad] { background: var(--bad); }
body.player[data-bg=miss] { background: var(--muted); }
body.player[data-bg=cloud] { background: var(--purple); }
