/* Party Night — phone controller. Portrait, one thumb, big targets, old-phone friendly. */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
body { font-size: 18px; -webkit-text-size-adjust: 100%; }
body.drawing { touch-action: none; }
#app {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  background: radial-gradient(600px 400px at 0% 0%, rgba(255, 79, 139, 0.18), transparent 70%), radial-gradient(600px 500px at 100% 100%, rgba(62, 193, 255, 0.14), transparent 70%), var(--bg);
}
#top { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); background: rgba(0, 0, 0, 0.25); min-height: 52px; }
#me { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.me-face { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; border: 2px solid rgba(255, 255, 255, 0.85); flex: none; }
.me-name { font-family: var(--font-display); font-weight: 600; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#roomcode { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.1em; color: var(--accent-2); font-size: 18px; }
#vipbtn { border: none; background: var(--accent-2); color: #14112b; font-weight: 800; border-radius: 20px; padding: 8px 12px; min-height: 40px; font-size: 15px; }
#timerbar { flex: none; height: 8px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
#timerbar i { display: block; height: 100%; background: var(--good); transform-origin: 0 50%; }
#timerbar.low i { background: var(--bad); }

#screen { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; position: relative; }
body.drawing #screen { overflow: hidden; }
.scr { min-height: 100%; display: flex; flex-direction: column; padding: 14px 16px 18px; gap: 12px; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
.scr-header { font-size: 15px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; text-align: center; }
.banner { border-radius: 16px; padding: 12px 14px; font-family: var(--font-display); font-weight: 600; font-size: 20px; text-align: center; animation: slideIn 0.35s ease-out; }
.tone-info { background: var(--accent-3); color: #0b1d33; }
.tone-good { background: var(--good); color: #0d2b1a; }
.tone-bad { background: var(--bad); color: #fff; }
@keyframes slideIn { from { transform: translateY(-12px); opacity: 0; } to { transform: none; opacity: 1; } }
.prompt { font-family: var(--font-display); font-weight: 600; font-size: 24px; line-height: 1.2; text-align: center; overflow-wrap: anywhere; }
.col { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.center-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 10px; }
.center-col.slim { flex: none; padding-top: 20px; }
.big-emoji { font-size: 84px; line-height: 1; }
.float { animation: floaty 2.4s ease-in-out infinite alternate; }
@keyframes floaty { to { transform: translateY(-10px) rotate(4deg); } }
.wait-msg { font-family: var(--font-display); font-weight: 700; font-size: 28px; line-height: 1.15; }
.wait-sub { color: var(--muted); font-size: 18px; }
.done-check { width: 130px; height: 130px; border-radius: 50%; background: var(--good); color: #0d2b1a; font-size: 84px; font-weight: 900; display: flex; align-items: center; justify-content: center; animation: pop 0.5s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes pop { from { transform: scale(0.2); } to { transform: none; } }

/* buttons */
.btn { border: none; border-radius: 18px; padding: 14px 18px; min-height: 54px; font-family: var(--font-display); font-weight: 600; font-size: 20px; background: var(--panel-2); color: var(--text); cursor: pointer; transition: transform 0.1s; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 5px 0 #a3245a; }
.btn.primary:disabled { box-shadow: none; }
.btn.big { font-size: 22px; min-height: 62px; width: 100%; }
.btn.ghost { background: transparent; border: 2px solid var(--line); }
.btn.link { background: none; color: var(--muted); font-size: 16px; min-height: 44px; text-decoration: underline; margin-top: auto; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.round { width: 56px; height: 56px; border-radius: 50%; padding: 0; font-size: 30px; flex: none; }
.btn.tool { padding: 8px 10px; min-height: 48px; font-size: 16px; flex: 1; }
.sticky-bottom { position: sticky; bottom: 0; padding-top: 8px; margin-top: auto; background: linear-gradient(transparent, var(--bg) 30%); }

/* text */
.text-in { width: 100%; font: inherit; font-size: 22px; padding: 16px; border-radius: 16px; border: 3px solid var(--panel-2); background: #fff7ea; color: #14112b; outline: none; resize: none; }
.text-in:focus { border-color: var(--accent-2); }
.counter { text-align: right; color: var(--muted); font-size: 14px; margin-top: -6px; }

/* choice */
.opts.list { display: flex; flex-direction: column; gap: 10px; }
.opts.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; grid-auto-rows: minmax(110px, auto); }
.opt { border: 3px solid transparent; border-radius: 18px; padding: 14px 16px; min-height: 58px; background: var(--panel); color: var(--text); text-align: left; font-size: 20px; font-weight: 800; display: flex; flex-direction: column; justify-content: center; gap: 2px; overflow-wrap: anywhere; }
.opts.grid .opt { text-align: center; align-items: center; font-family: var(--font-display); font-size: 22px; font-weight: 700; }
.opt:active { transform: scale(0.97); }
.opt.disabled { opacity: 0.38; }
.opt.chosen, .opt.on { border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--accent-2) inset; }
.opt.toggle.on::after { content: '✓'; position: absolute; }
.opt-sub { font-size: 14px; font-weight: 700; opacity: 0.8; }
.hint { text-align: center; color: var(--muted); font-weight: 700; }

/* number */
.num-wrap { display: flex; justify-content: center; }
.num-display { background: #fff7ea; color: #14112b; border: none; border-radius: 20px; font-family: var(--font-display); font-weight: 700; font-size: 44px; padding: 10px 24px; min-width: 70%; }
.num-exact { font-family: var(--font-display); font-size: 40px; text-align: center; width: 80%; border-radius: 20px; border: 3px solid var(--accent-2); padding: 10px; }
.num-row { display: flex; align-items: center; gap: 12px; }
.slider { flex: 1; height: 44px; -webkit-appearance: none; appearance: none; background: transparent; }
.slider::-webkit-slider-runnable-track { height: 12px; border-radius: 6px; background: var(--panel-2); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 38px; height: 38px; border-radius: 50%; background: var(--accent-2); margin-top: -13px; border: 3px solid #fff; }
.slider::-moz-range-track { height: 12px; border-radius: 6px; background: var(--panel-2); }
.slider::-moz-range-thumb { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-2); border: 3px solid #fff; }
.num-range { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; gap: 8px; }

/* draw */
.scr-draw { height: 100%; padding: 8px 10px 10px; gap: 8px; }
.scr-draw .prompt { font-size: 20px; }
.draw-col { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.draw-wrap { flex: 1; min-height: 160px; display: flex; align-items: center; justify-content: center; }
.draw-canvas { display: block; border-radius: 14px; background: #fff; touch-action: none; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35); }
.draw-tools, .draw-actions { display: flex; gap: 8px; align-items: center; }
.swatches { display: flex; flex-wrap: nowrap; gap: 5px; justify-content: center; flex: 1; min-width: 0; }
.sw { flex: 1 1 0; min-width: 22px; max-width: 44px; height: auto; aspect-ratio: 1 / 1; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.4); padding: 0; }
.sw.on { border-color: var(--accent-2); transform: scale(1.12); box-shadow: 0 0 0 2px var(--bg), 0 0 0 5px var(--accent-2); }
.brushes { display: flex; gap: 4px; }
.br { width: 48px; height: 48px; border-radius: 12px; border: 2px solid transparent; background: var(--panel); display: flex; align-items: center; justify-content: center; padding: 0; }
.br i { display: block; border-radius: 50%; background: var(--text); }
.br.on { border-color: var(--accent-2); }
.draw-actions .btn.primary { flex: 1.3; min-height: 48px; padding: 8px 12px; }

/* buzzer / react */
.buzzer { width: min(78vw, 320px); height: min(78vw, 320px); border-radius: 50%; border: none; background: radial-gradient(circle at 35% 30%, #ff8db4, var(--accent) 60%, #b8205a); box-shadow: 0 14px 0 #7a1340, 0 18px 30px rgba(0, 0, 0, 0.4); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 48px; touch-action: none; }
.buzzer:active, .buzzer.hit { transform: translateY(10px); box-shadow: 0 4px 0 #7a1340; }
.buzzer.disabled { filter: grayscale(1); opacity: 0.5; }
.react-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; flex: 1; }
.react-btn { position: relative; border: none; border-radius: 24px; background: var(--panel); font-size: 56px; min-height: 110px; overflow: visible; touch-action: manipulation; }
.react-btn.tap { animation: tap 0.25s ease-out; }
@keyframes tap { 50% { transform: scale(0.9); } }
.react-float { position: absolute; top: 10%; font-size: 40px; pointer-events: none; animation: rf 0.9s ease-out forwards; }
@keyframes rf { to { transform: translateY(-90px) scale(1.4); opacity: 0; } }

/* sent overlay */
#sent { position: absolute; inset: 0; top: 52px; z-index: 20; background: rgba(21, 17, 46, 0.9); display: flex; align-items: center; justify-content: center; }
.sent-inner { text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 30px; animation: pop 0.4s cubic-bezier(.2, 1.8, .4, 1); }
.sent-check { width: 110px; height: 110px; margin: 0 auto 10px; border-radius: 50%; background: var(--good); color: #0d2b1a; font-size: 70px; display: flex; align-items: center; justify-content: center; }

/* join */
.join { min-height: 100%; display: flex; flex-direction: column; gap: 10px; padding: 26px 22px; justify-content: center; max-width: 460px; margin: 0 auto; }
.join .logo { font-family: var(--font-display); font-weight: 700; font-size: 52px; text-align: center; margin-bottom: 18px; }
.join .logo span { display: inline-block; margin: 0 6px; }
.join .logo span:first-child { color: var(--accent-2); transform: rotate(-4deg); }
.join .logo span:last-child { color: var(--accent); transform: rotate(3deg); }
.lbl { font-weight: 800; color: var(--muted); font-size: 15px; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 6px; }
.join-code, .join-name { width: 100%; font: inherit; font-size: 26px; padding: 14px 16px; border-radius: 16px; border: 3px solid var(--panel-2); background: #fff7ea; color: #14112b; outline: none; }
.join-code { font-family: var(--font-display); font-weight: 700; font-size: 40px; letter-spacing: 0.3em; text-align: center; text-transform: uppercase; }
.join-code:focus, .join-name:focus { border-color: var(--accent-2); }
.join .btn.primary { margin-top: 14px; }
.err { background: var(--bad); color: #fff; padding: 10px 14px; border-radius: 12px; font-weight: 800; text-align: center; }
.join-foot { text-align: center; color: var(--muted); font-size: 15px; margin-top: 8px; }

/* lobby */
.lobby-me { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 6px; }
.avatar-btn { position: relative; background: none; border: none; padding: 4px; }
.avatar-btn .edit { position: absolute; right: 0; top: 0; background: var(--panel-2); border-radius: 50%; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.avatar-btn .pn-avatar-name { font-size: 24px !important; }
.lobby-hello { font-family: var(--font-display); font-weight: 700; font-size: 26px; color: var(--accent-2); }
.section-title { font-family: var(--font-display); font-weight: 700; font-size: 22px; margin-top: 6px; }
.game-list { display: flex; flex-direction: column; gap: 8px; }
.game-item { display: flex; gap: 12px; align-items: center; text-align: left; border: 3px solid transparent; border-radius: 18px; background: var(--panel); padding: 10px 12px; min-height: 64px; }
.game-item.sel { border-color: var(--accent-2); background: var(--panel-2); }
.gi-emoji { font-size: 36px; flex: none; width: 46px; text-align: center; }
.gi-text { display: flex; flex-direction: column; min-width: 0; }
.gi-text b { font-family: var(--font-display); font-weight: 700; font-size: 19px; }
.gi-text small, .picked small { color: var(--muted); font-size: 14px; display: block; }
.gi-meta { font-size: 12px !important; }
.picked { display: flex; gap: 12px; align-items: center; background: var(--panel); border-radius: 18px; padding: 12px 16px; text-align: left; }
.picked b { font-family: var(--font-display); font-size: 20px; }
.emoji-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.emo { font-size: 32px; min-height: 56px; border-radius: 14px; border: 3px solid transparent; background: var(--panel); }
.emo.on { border-color: var(--accent-2); }
.emo.taken { opacity: 0.25; }
.award-chip { background: var(--panel-2); border-radius: 14px; padding: 8px 14px; font-weight: 800; color: var(--accent-2); }
.vip-row { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 14px; }

/* sheet / toast / conn */
#sheet { position: absolute; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.55); display: flex; align-items: flex-end; }
.sheet-box { width: 100%; background: var(--panel); border-radius: 24px 24px 0 0; padding: 18px 16px max(18px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; animation: up 0.25s ease-out; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
#toast { position: absolute; left: 12px; right: 12px; top: 64px; z-index: 50; background: var(--accent-2); color: #14112b; font-weight: 800; padding: 12px 16px; border-radius: 14px; text-align: center; animation: slideIn 0.3s; }
#conn { position: absolute; left: 0; right: 0; bottom: 0; z-index: 60; background: var(--bad); color: #fff; text-align: center; font-weight: 800; padding: 8px; }
.custom-root { min-height: 100%; }
.toggle-row { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; align-items: center; text-align: left; gap: 0 12px; background: var(--panel); border: none; border-radius: 18px; padding: 12px 16px; min-height: 60px; font-family: var(--font-display); font-weight: 600; font-size: 18px; }
.toggle-row small { grid-column: 1; color: var(--muted); font-family: var(--font-body); font-weight: 700; font-size: 13px; }
.toggle-row .switch { grid-column: 2; grid-row: 1 / span 2; width: 52px; height: 30px; border-radius: 15px; background: var(--panel-2); position: relative; transition: background 0.2s; }
.toggle-row .switch::after { content: ''; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.toggle-row.on .switch { background: var(--good); }
.toggle-row.on .switch::after { transform: translateX(22px); }
