:root {
  --blue: #2f9bff;
  --blue-d: #1b6fd1;
  --sky: #bfe6ff;
  --yellow: #ffd23f;
  --pink: #ff6fae;
  --red: #ff5a5f;
  --ink: #1d2b4a;
  --muted: #6b7a99;
  --panel: #ffffff;
  --line: #d9e8f7;
  --radius: 18px;
  --shadow: 0 6px 0 rgba(22, 76, 140, 0.18), 0 10px 30px rgba(22, 76, 140, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Jua', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #7cc9ff 0%, #bfe6ff 45%, #e9f7ff 100%);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.screen { min-height: 100%; }

/* ---------------------------------------------------------------- buttons */
.btn {
  border: 0; border-radius: 14px; padding: 12px 16px; cursor: pointer;
  background: #eef6ff; color: var(--ink); box-shadow: 0 4px 0 #c7dcf2;
  transition: transform 0.06s, box-shadow 0.06s, filter 0.15s;
  font-size: 17px; line-height: 1.1; touch-action: manipulation;
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #c7dcf2; }
.btn.primary { background: var(--blue); color: #fff; box-shadow: 0 4px 0 var(--blue-d); }
.btn.primary:active { box-shadow: 0 1px 0 var(--blue-d); }
.btn.huge { width: 100%; font-size: 24px; padding: 16px; border-radius: 18px; }
.btn.small { padding: 8px 12px; font-size: 15px; }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.icon-btn {
  border: 0; background: rgba(255, 255, 255, 0.85); width: 40px; height: 40px; border-radius: 12px;
  font-size: 18px; cursor: pointer; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12); flex: 0 0 auto;
}
.lang-btn {
  border: 0; background: rgba(255, 255, 255, 0.85); height: 40px; padding: 0 12px; border-radius: 12px; white-space: nowrap;
  cursor: pointer; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
}
.row2 { display: flex; gap: 10px; }
.row2 > * { flex: 1; }

/* ---------------------------------------------------------------- home */
#home { max-width: 1120px; margin: 0 auto; padding: 12px 16px 28px; }
.home-top { display: flex; align-items: center; gap: 8px; }
.home-top .grow { flex: 1; }
.brand { color: #fff; text-decoration: none; letter-spacing: 2px; font-size: 18px; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15); }
.logo { text-align: center; margin: 6px 0 14px; position: relative; }
.logo h1 { margin: 0; font-weight: normal; line-height: 1; display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.logo h1 span {
  font-size: clamp(44px, 9vw, 84px); color: #fff; letter-spacing: 1px;
  -webkit-text-stroke: 3px #1b6fd1; paint-order: stroke fill;
  text-shadow: 0 6px 0 #1b6fd1, 0 10px 20px rgba(0, 60, 140, 0.35);
}
.logo h1 .l2 { color: var(--yellow); -webkit-text-stroke-color: #e07a00; text-shadow: 0 6px 0 #e07a00, 0 10px 20px rgba(140, 60, 0, 0.3); }
.logo .tag { margin: 10px 0 0; font-size: clamp(16px, 2.6vw, 20px); color: #0f4d8f; }
.logo-balloons { position: absolute; inset: 0; pointer-events: none; }
.logo-balloons i {
  position: absolute; width: 38px; height: 44px; border-radius: 50% 50% 48% 48%;
  background: radial-gradient(circle at 35% 30%, #fff 0 12%, #7fd3ff 30%, #2f9bff 80%);
  animation: floaty 3.2s ease-in-out infinite;
}
.logo-balloons i:nth-child(1) { left: 6%; top: 10px; }
.logo-balloons i:nth-child(2) { right: 8%; top: 0; background: radial-gradient(circle at 35% 30%, #fff 0 12%, #ffb3d4 30%, #ff6fae 80%); animation-delay: -1s; }
.logo-balloons i:nth-child(3) { right: 16%; top: 60px; width: 26px; height: 30px; background: radial-gradient(circle at 35% 30%, #fff 0 12%, #ffe58a 30%, #ffc400 80%); animation-delay: -2s; }
@keyframes floaty { 50% { transform: translateY(-10px) rotate(6deg); } }

.home-grid { display: grid; grid-template-columns: 360px 1fr; grid-template-rows: auto auto; gap: 16px; }
.panel { background: var(--panel); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.panel h2 { margin: 0 0 10px; font-size: 20px; font-weight: normal; }
.profile { grid-row: span 2; display: flex; flex-direction: column; gap: 12px; }
.char-pick { display: flex; align-items: center; justify-content: center; gap: 6px; }
.char-pick canvas { width: 150px; height: 150px; border-radius: 50%; background: radial-gradient(circle at 50% 60%, #e8f6ff, #bfe6ff); }
.arrow { border: 0; background: #eef6ff; width: 44px; height: 44px; border-radius: 50%; font-size: 26px; cursor: pointer; box-shadow: 0 3px 0 #c7dcf2; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px #d9e8f7; cursor: pointer; padding: 0; }
.swatch.on { box-shadow: 0 0 0 3px var(--ink); transform: scale(1.1); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 15px; color: var(--muted); }
.field input, .code-join input, .chat-form input, .gchat input {
  border: 2px solid var(--line); border-radius: 12px; padding: 11px 12px; font-size: 18px; background: #f7fbff; outline: none; min-width: 0;
}
.field input:focus, .code-join input:focus, .chat-form input:focus { border-color: var(--blue); background: #fff; }
.code-join { display: flex; gap: 8px; }
.code-join input { flex: 1; text-transform: uppercase; letter-spacing: 3px; text-align: center; }
.invite-box { background: #fff7d6; border-radius: 12px; padding: 10px 12px; text-align: center; }
.invite-box b { letter-spacing: 2px; color: #e07a00; }
.conn-note { margin: 0; min-height: 18px; font-size: 14px; color: var(--muted); text-align: center; }

.rooms-head { display: flex; align-items: baseline; justify-content: space-between; }
.online { color: #1f9d55; font-size: 15px; }
.room-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 280px; overflow: auto; }
.room-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: #f3f9ff; }
.room-list .r-main { flex: 1; min-width: 0; }
.room-list .r-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-list .r-sub { font-size: 13px; color: var(--muted); }
.room-list .r-n { font-size: 15px; color: var(--blue-d); }
.empty { color: var(--muted); margin: 8px 0 0; }
.how-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.how-list li { display: flex; gap: 10px; align-items: flex-start; background: #f3f9ff; border-radius: 14px; padding: 10px 12px; font-size: 15px; line-height: 1.35; }
.how-list b { font-size: 24px; line-height: 1; }
.items-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 12px 0 6px; font-size: 14px; color: var(--muted); }
.items-legend span { display: inline-flex; align-items: center; gap: 4px; }
.items-legend canvas { width: 26px; height: 26px; }
.keys { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.foot { text-align: center; margin-top: 18px; }
.foot a { color: #0f4d8f; }

/* ---------------------------------------------------------------- room */
#room { max-width: 1120px; margin: 0 auto; padding: 12px 16px 24px; }
.room-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.room-code { flex: 1; text-align: center; font-size: 20px; color: #0f4d8f; }
.room-code b { letter-spacing: 3px; background: #fff; border-radius: 10px; padding: 4px 10px; color: var(--ink); }
.room-grid { display: grid; grid-template-columns: 1fr 360px; grid-template-rows: auto 1fr; gap: 16px; }
.players { grid-row: span 2; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; }
.player-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.player-list li {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 14px; background: #f3f9ff;
  border: 3px solid transparent; position: relative; min-height: 64px;
}
.player-list li.t0 { border-color: #ffb3b5; background: #fff3f3; }
.player-list li.t1 { border-color: #a9ccff; background: #f0f6ff; }
.player-list li.me { box-shadow: 0 0 0 2px var(--yellow); }
.player-list li.off { opacity: 0.5; }
.player-list canvas { width: 48px; height: 48px; flex: 0 0 auto; }
.player-list .p-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-list .p-tag { font-size: 12px; color: var(--muted); display: block; }
.player-list .kick { border: 0; background: transparent; cursor: pointer; font-size: 16px; opacity: 0.5; }
.player-list .empty-slot { color: #b6c6dc; justify-content: center; border: 3px dashed #d9e8f7; background: transparent; }
.team-pick { display: flex; gap: 10px; margin-bottom: 10px; }
.team-pick .btn { flex: 1; }
.btn.team0 { background: #ffe1e2; box-shadow: 0 4px 0 #ffb3b5; }
.btn.team1 { background: #dcebff; box-shadow: 0 4px 0 #a9ccff; }
.btn.team0.on { background: var(--red); color: #fff; box-shadow: 0 4px 0 #c7363b; }
.btn.team1.on { background: var(--blue); color: #fff; box-shadow: 0 4px 0 var(--blue-d); }
.settings { display: flex; flex-direction: column; gap: 10px; }
.settings-box { display: flex; flex-direction: column; gap: 10px; }
.set-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.set-row > span { color: var(--muted); font-size: 15px; flex: 0 0 auto; }
.seg { display: flex; gap: 4px; background: #eef6ff; border-radius: 12px; padding: 3px; flex-wrap: wrap; justify-content: flex-end; }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 7px 10px; cursor: pointer; font-size: 15px; }
.seg button.on { background: var(--blue); color: #fff; }
.seg button:disabled { cursor: default; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { border: 0; width: 34px; height: 34px; border-radius: 10px; background: #eef6ff; cursor: pointer; font-size: 20px; }
.stepper b { min-width: 28px; text-align: center; font-weight: normal; font-size: 18px; }
.host-note, .auto-note { margin: 0; color: var(--muted); font-size: 14px; text-align: center; min-height: 1em; }
.chat { display: flex; flex-direction: column; min-height: 220px; }
.chat-log { list-style: none; margin: 0 0 8px; padding: 0; flex: 1; overflow: auto; max-height: 260px; font-size: 15px; display: flex; flex-direction: column; gap: 4px; }
.chat-log li b { color: var(--blue-d); font-weight: normal; }
.chat-log li.sys { color: var(--muted); font-size: 14px; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; font-size: 16px; padding: 9px 10px; }

/* ---------------------------------------------------------------- game */
#game { position: fixed; inset: 0; display: flex; flex-direction: column; background: #0f3d66; user-select: none; -webkit-user-select: none; touch-action: none; }
.hud-top { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top)); background: rgba(0, 0, 0, 0.25); }
.score-bar { flex: 1; display: flex; gap: 6px; overflow: hidden; align-items: center; min-width: 0; }
.score-chip { display: flex; align-items: center; gap: 4px; background: rgba(255, 255, 255, 0.9); border-radius: 12px; padding: 3px 8px 3px 4px; font-size: 14px; white-space: nowrap; flex: 0 1 auto; min-width: 0; }
.score-chip canvas { width: 24px; height: 24px; flex: 0 0 auto; }
.score-chip .nm { overflow: hidden; text-overflow: ellipsis; max-width: 70px; }
.score-chip.out { opacity: 0.45; }
.score-chip .w { color: #e07a00; }
.team-score { display: flex; align-items: center; gap: 8px; font-size: 22px; color: #fff; }
.team-score .t0 { background: var(--red); border-radius: 10px; padding: 2px 12px; }
.team-score .t1 { background: var(--blue); border-radius: 10px; padding: 2px 12px; }
.timer { color: #fff; font-size: 22px; min-width: 64px; text-align: center; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3); }
.timer.sudden { color: #ffd23f; animation: pulse 0.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.stage { flex: 1 1 auto; position: relative; min-height: 0; overflow: hidden; }
.stage canvas { position: absolute; left: 0; top: 0; }
.banner {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); text-align: center; pointer-events: none;
  color: #fff; font-size: clamp(34px, 8vw, 72px); -webkit-text-stroke: 3px #1b3a6b; paint-order: stroke fill;
  text-shadow: 0 6px 0 #1b3a6b; white-space: nowrap; animation: bannerIn 0.35s cubic-bezier(.2, 1.6, .5, 1);
}
.banner small { display: block; font-size: 0.42em; -webkit-text-stroke-width: 2px; margin-top: 6px; }
@keyframes bannerIn { from { transform: translate(-50%, -50%) scale(0.3); opacity: 0; } }
.feed { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; pointer-events: none; }
.feed div { background: rgba(0, 0, 0, 0.5); color: #fff; border-radius: 10px; padding: 3px 10px; font-size: 14px; animation: fadeOut 4s forwards; }
@keyframes fadeOut { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
.toasts { position: absolute; left: 8px; top: 8px; display: flex; flex-direction: column; gap: 4px; pointer-events: none; max-width: 55%; }
.toasts div { background: rgba(255, 255, 255, 0.9); border-radius: 10px; padding: 3px 10px; font-size: 14px; animation: fadeOut 6s forwards; }
.toasts b { color: var(--blue-d); font-weight: normal; }
.spec-note { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); background: rgba(0, 0, 0, 0.55); color: #fff; border-radius: 12px; padding: 6px 14px; font-size: 15px; pointer-events: none; white-space: nowrap; }
.tip {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(255, 255, 255, 0.95); color: var(--ink);
  border-radius: 16px; padding: 10px 16px; font-size: 17px; text-align: center; pointer-events: none; box-shadow: var(--shadow);
  width: max-content; max-width: 92%; animation: bannerIn 0.4s cubic-bezier(.2, 1.4, .5, 1);
}
.tip b { color: var(--blue-d); font-weight: normal; }
.controls .tip { top: 12px; transform: translateX(-50%); z-index: 2; }
.gchat { position: absolute; left: 50%; bottom: 44px; transform: translateX(-50%); width: min(420px, 90%); }
.gchat input { width: 100%; }
.hud-bottom { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: rgba(0, 0, 0, 0.25); color: #fff; }
.stats { display: flex; gap: 10px; font-size: 16px; }
.stats span { display: inline-flex; align-items: center; gap: 3px; background: rgba(255, 255, 255, 0.15); border-radius: 10px; padding: 2px 8px; }
.stats span.flash { animation: flash 0.6s; }
@keyframes flash { 30% { background: #ffd23f; color: #3a2a00; transform: scale(1.2); } }
.emotes { display: flex; gap: 4px; margin-left: auto; }
.emotes button { border: 0; background: rgba(255, 255, 255, 0.15); border-radius: 10px; width: 36px; height: 34px; font-size: 18px; cursor: pointer; }
.emotes button:active { transform: scale(0.9); }
.key-hint { font-size: 13px; opacity: 0.7; white-space: nowrap; }
.controls { display: none; }
/* scrolls when the card is taller than the screen (a phone on its side); margin:auto centres it otherwise */
.overlay { position: absolute; inset: 0; display: flex; background: rgba(8, 30, 60, 0.55); z-index: 5; padding: 16px; overflow-y: auto; touch-action: pan-y; }
.result-card { margin: auto; background: #fff; border-radius: 22px; padding: 20px; width: min(440px, 100%); box-shadow: var(--shadow); text-align: center; animation: bannerIn 0.4s cubic-bezier(.2, 1.4, .5, 1); }
.result-card h2 { margin: 0 0 12px; font-weight: normal; font-size: 30px; }
.result-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.result-list li { display: flex; align-items: center; gap: 8px; background: #f3f9ff; border-radius: 12px; padding: 6px 10px; }
.result-list li.first { background: #fff4c7; }
.result-list canvas { width: 36px; height: 36px; }
.result-list .rk { width: 26px; text-align: center; font-size: 18px; }
.result-list .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-list .st { font-size: 13px; color: var(--muted); white-space: nowrap; }
.result-note { color: var(--muted); margin: 0 0 12px; }
.share-row { margin-bottom: 14px; }

/* party relay: the host's pick of the next game, and everyone's notice before moving */
.relay { margin: 0 0 14px; }
.relay h3 { margin: 0 0 8px; font-weight: normal; font-size: 17px; color: var(--muted); }
.relay-games { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.relay-game {
  border: 0; border-radius: 14px; padding: 9px 10px; cursor: pointer; text-align: left; background: #eef6ff;
  box-shadow: 0 4px 0 #c7dcf2; display: flex; flex-direction: column; gap: 2px; min-width: 0; touch-action: manipulation;
}
.relay-game:active { transform: translateY(3px); box-shadow: 0 1px 0 #c7dcf2; }
.relay-game:disabled { opacity: 0.5; cursor: default; transform: none; }
.relay-game b { font-weight: normal; font-size: 16px; }
.relay-game small { font-size: 12px; color: var(--muted); }
.relay-hint { margin: 0; color: var(--muted); font-size: 14px; word-break: keep-all; text-wrap: balance; }
.relay:not(.pick) h3, .relay:not(.pick) .relay-games, .relay.pick .relay-hint { display: none; }
.settings .relay { margin: 4px 0 0; padding-top: 12px; border-top: 2px dashed var(--line); text-align: center; }
.relay-banner {
  position: fixed; left: 50%; top: max(12px, env(safe-area-inset-top)); transform: translateX(-50%); z-index: 60;
  width: min(460px, calc(100% - 24px)); background: #fff; border-radius: 18px; padding: 12px 14px; box-shadow: var(--shadow);
  text-align: center; animation: dropIn 0.3s cubic-bezier(.2, 1.4, .5, 1);
}
.relay-banner p { margin: 0 0 10px; font-size: 17px; line-height: 1.35; }
@keyframes dropIn { from { transform: translate(-50%, -24px); opacity: 0; } }

/* touch controls */
body.touch .key-hint { display: none; }
body.touch .controls { display: block; position: relative; flex: 0 0 auto; }
body.touch.portrait .controls { flex: 1 1 auto; min-height: 170px; background: rgba(0, 0, 0, 0.18); }
body.touch.landscape .controls { position: absolute; left: 0; right: 0; top: 52px; bottom: 44px; pointer-events: none; }
.stick-zone { position: absolute; left: 0; top: 0; bottom: 0; width: 55%; pointer-events: auto; touch-action: none; }
.stick-base {
  position: absolute; width: 130px; height: 130px; margin: -65px 0 0 -65px; left: 32%; top: 55%;
  border-radius: 50%; background: rgba(255, 255, 255, 0.14); border: 3px solid rgba(255, 255, 255, 0.35);
}
.stick-knob { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; background: rgba(255, 255, 255, 0.85); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2); }
.bomb-btn {
  position: absolute; right: 8%; top: 50%; transform: translateY(-50%); width: 104px; height: 104px; border-radius: 50%; border: 0;
  background: radial-gradient(circle at 35% 30%, #bfe9ff, #2f9bff 70%); box-shadow: 0 6px 0 #1b6fd1, 0 10px 20px rgba(0, 0, 0, 0.3);
  font-size: 44px; pointer-events: auto; touch-action: none;
}
.bomb-btn.pressed { transform: translateY(calc(-50% + 4px)); box-shadow: 0 2px 0 #1b6fd1; }
.bomb-btn.needle { background: radial-gradient(circle at 35% 30%, #ffd1e4, #ff4d8a 70%); box-shadow: 0 6px 0 #c02a60; }
body.touch.landscape .stick-zone { width: 30%; }
body.touch.landscape .stick-base { left: 50%; top: 60%; }
body.touch.landscape .bomb-btn { right: 4%; top: 62%; }
body.touch .emotes button { width: 34px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: rgba(20, 30, 50, 0.9); color: #fff;
  border-radius: 14px; padding: 10px 16px; z-index: 50; font-size: 16px; max-width: 90vw; text-align: center;
}

/* ---------------------------------------------------------------- narrow */
@media (max-width: 860px) {
  .home-grid { grid-template-columns: 1fr; }
  .profile { grid-row: auto; }
  .how-list { grid-template-columns: 1fr; }
  .room-grid { grid-template-columns: 1fr; }
  .players { grid-row: auto; }
  .player-list { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .logo { margin: 0 0 10px; }
  .logo-balloons i:nth-child(1) { left: -6px; top: 60px; width: 26px; height: 30px; }
  .logo-balloons i:nth-child(2) { right: -4px; top: 56px; width: 26px; height: 30px; }
  .logo-balloons i:nth-child(3) { display: none; }
  .hud-bottom { flex-wrap: wrap; gap: 6px; padding: 4px 6px; }
  .stats { gap: 5px; font-size: 14px; }
  .stats span { padding: 2px 6px; }
  .emotes button { width: 30px; height: 30px; font-size: 16px; }
  .timer { font-size: 18px; min-width: 50px; flex: 1; }
  .hud-top { flex-wrap: wrap; row-gap: 4px; }
  .score-bar { order: 5; flex: 1 1 100%; justify-content: center; gap: 4px; }
  .score-chip { padding: 2px 6px 2px 2px; font-size: 13px; flex: 0 0 auto; }
  .score-chip canvas { width: 20px; height: 20px; }
  .score-chip .nm { display: none; }
  .player-list li { min-height: 56px; }
  .player-list canvas { width: 40px; height: 40px; }
}

/* ---------------------------------------------------------------- phone title screen
   On phones the home screen is one full screen like a game title, never a scrolling page:
   logo, character, the play buttons; open rooms and how-to live in bottom sheets. */
.home-dock, .sheet-close, .sheet-backdrop { display: none; }

@media (max-width: 860px), (max-height: 600px) and (orientation: landscape) {
  html, body { height: 100%; }
  #home {
    height: 100vh; height: 100dvh; max-width: none; overflow: hidden;
    display: flex; flex-direction: column;
    padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    gap: clamp(4px, 1.2vh, 10px);
  }
  #home .home-top { flex: 0 0 auto; }
  #home .home-top .icon-btn, #home .lang-btn { height: 36px; }
  #home .home-top .icon-btn { width: 36px; font-size: 16px; }
  .brand { font-size: 15px; }
  .logo { flex: 0 0 auto; margin: 0; }
  .logo-balloons { display: none; }
  .logo h1 { gap: 8px; }
  .logo h1 span { font-size: clamp(34px, min(12vw, 7.2vh), 64px); -webkit-text-stroke-width: 2px; text-shadow: 0 4px 0 #1b6fd1, 0 8px 14px rgba(0, 60, 140, 0.3); }
  .logo h1 .l2 { text-shadow: 0 4px 0 #e07a00, 0 8px 14px rgba(140, 60, 0, 0.25); }
  .logo .tag { margin-top: clamp(2px, 0.8vh, 8px); font-size: clamp(12px, min(3.6vw, 2.2vh), 16px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .home-grid { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 0; }
  .profile {
    flex: 1 1 auto; min-height: 0; grid-row: auto;
    display: flex; flex-direction: column; justify-content: space-between;
    gap: clamp(6px, 1.3vh, 12px); padding: clamp(10px, 1.6vh, 16px) 14px;
  }
  .char-pick { flex: 1 1 auto; min-height: 0; gap: 10px; }
  .char-pick canvas { height: 100%; width: auto; max-height: min(34vh, 280px, 62vw); min-height: 72px; aspect-ratio: 1; }
  .arrow { width: 40px; height: 40px; font-size: 24px; flex: 0 0 auto; }
  .swatches { flex: 0 0 auto; flex-wrap: nowrap; gap: clamp(4px, 1.5vw, 8px); }
  .swatch { width: clamp(22px, 7vw, 30px); height: clamp(22px, 7vw, 30px); border-width: 2px; flex: 0 0 auto; }
  .field { flex: 0 0 auto; }
  .field > span { display: none; }
  .field input { padding: clamp(7px, 1.2vh, 11px) 12px; font-size: 17px; text-align: center; }
  .invite-box { padding: 6px 10px; font-size: 15px; }
  .btn.huge { font-size: clamp(20px, 3vh, 24px); padding: clamp(10px, 1.9vh, 16px); flex: 0 0 auto; }
  .profile .row2 { flex: 0 0 auto; }
  .profile .row2 .btn, .code-join .btn { padding: clamp(8px, 1.3vh, 12px) 10px; font-size: 16px; }
  .code-join { flex: 0 0 auto; }
  .code-join input { padding: clamp(7px, 1.2vh, 11px) 10px; font-size: 16px; }
  .conn-note { min-height: 0; font-size: 13px; }
  .conn-note:empty { display: none; }
  #home.invited #quickBtn { font-size: 17px; padding: clamp(8px, 1.3vh, 12px); }
  .foot { display: none; }

  /* bottom dock and sheets */
  .home-dock { display: flex; flex: 0 0 auto; gap: 8px; }
  .dock-btn {
    flex: 1; border: 0; border-radius: 14px; padding: clamp(8px, 1.3vh, 11px) 10px; font-size: 15px; cursor: pointer;
    background: rgba(255, 255, 255, 0.85); color: #0f4d8f; box-shadow: 0 3px 0 rgba(22, 76, 140, 0.18);
  }
  .dock-btn b { font-weight: normal; background: #2f9bff; color: #fff; border-radius: 10px; padding: 1px 8px; margin-left: 4px; }
  .panel.rooms, .panel.how {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; max-height: 78dvh; overflow: auto;
    border-radius: 22px 22px 0 0; padding: 16px 16px max(18px, env(safe-area-inset-bottom));
    transform: translateY(105%); transition: transform 0.22s ease-out; box-shadow: 0 -8px 30px rgba(10, 40, 90, 0.25);
  }
  .panel.rooms .room-list { max-height: none; }
  #home.sheet-rooms .panel.rooms, #home.sheet-how .panel.how { transform: none; }
  .sheet-close { display: block; border: 0; background: #eef6ff; width: 36px; height: 36px; border-radius: 50%; font-size: 16px; cursor: pointer; margin-left: 8px; }
  .panel .rooms-head { align-items: center; }
  .panel .rooms-head h2 { margin: 0; flex: 1; }
  .panel.rooms .rooms-head { margin-bottom: 10px; }
  .panel.how .rooms-head { margin-bottom: 10px; }
  .sheet-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(8, 30, 60, 0.4); }
  .sheet-backdrop[hidden] { display: none; }
}

/* phone on its side: logo on top, character on the left, buttons on the right */
@media (max-height: 600px) and (orientation: landscape) {
  #home .home-top { position: absolute; left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); top: max(6px, env(safe-area-inset-top)); z-index: 2; }
  .logo h1 span { font-size: clamp(30px, 10vh, 46px); }
  .logo .tag { display: none; }
  .profile {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); grid-auto-rows: auto;
    align-content: center; column-gap: 18px; row-gap: clamp(5px, 1.4vh, 9px);
  }
  .profile > * { grid-column: 2; }
  .profile > .char-pick { grid-column: 1; grid-row: 1 / span 5; height: 100%; min-height: 0; }
  .profile > .swatches { grid-column: 1; grid-row: 6 / span 2; align-self: start; justify-self: center; display: grid; grid-template-columns: repeat(5, auto); gap: 6px 10px; }
  .char-pick canvas { max-height: min(46vh, 180px); }
  .swatch { width: clamp(20px, 5vh, 26px); height: clamp(20px, 5vh, 26px); }
  .btn.huge { font-size: 20px; padding: 10px; }
  .panel.rooms, .panel.how { left: 50%; right: auto; width: min(640px, 100%); transform: translate(-50%, 105%); max-height: 88dvh; }
  #home.sheet-rooms .panel.rooms, #home.sheet-how .panel.how { transform: translate(-50%, 0); }
}
/* a small phone on its side: the top buttons (with 의견/Feedback) would cover the centered logo, so it starts after BREYES */
@media (max-height: 600px) and (orientation: landscape) and (max-width: 760px) {
  .logo h1 { justify-content: flex-start; padding-left: 96px; }
}
/* the narrowest phones (320px): 의견/Feedback and 한국어 must still fit on one line beside BREYES */
@media (max-width: 340px) {
  #home .home-top { gap: 6px; }
  #home .lang-btn { padding: 0 7px; font-size: 13px; }
}
