* { box-sizing: border-box; }

/* Native hidden must win over component display styles. Without this, hidden menu/game screens stayed visible and buttons appeared non-functional. */
[hidden] { display: none !important; }

:root {
  --bg: #070411;
  --void: #0d071b;
  --panel: #281356;
  --panel-2: #3a1d75;
  --panel-3: #4c278f;
  --ink: #fff5c4;
  --muted: #c9b8f3;
  --yellow: #ffdf4d;
  --orange: #ff8b28;
  --pink: #ff5d92;
  --blue: #41c5ff;
  --green: #66e23f;
  --dark-green: #176c2b;
  --outline: #07020e;
  --purple: #7c55e8;
  --shadow: #05020a;
}
html, body { margin:0; width:100vw; height:100dvh; overflow:hidden; background:var(--bg); color:var(--ink); }
body { font-family:"Courier New", monospace; font-weight:900; user-select:none; -webkit-user-select:none; -webkit-touch-callout:none; touch-action:manipulation; }
body::before { content:""; position:fixed; inset:0; pointer-events:none; background:
  repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 36px),
  repeating-linear-gradient(90deg, rgba(255,255,255,.018) 0 1px, transparent 1px 36px),
  repeating-linear-gradient(135deg, transparent 0 24px, rgba(133,87,255,.08) 24px 27px, transparent 27px 52px),
  radial-gradient(circle at 50% 16%, rgba(97,56,190,.48), transparent 44%);
}
button, input { font-family:inherit; font-weight:900; }
button { cursor:pointer; border:4px solid var(--outline); color:var(--ink); background:linear-gradient(#855df0 0%, #6035bd 48%, #33166e 52%, #271150 100%); box-shadow:inset 0 4px 0 rgba(255,255,255,.22), inset 0 -5px 0 rgba(0,0,0,.32), 5px 5px 0 var(--shadow); text-transform:uppercase; text-shadow:2px 2px 0 var(--shadow); letter-spacing:.02em; }
button:hover:not(:disabled), button.active { filter:brightness(1.13); outline:4px solid var(--yellow); }
button:active:not(:disabled) { transform:translate(2px,2px); box-shadow:inset 0 4px 0 rgba(255,255,255,.18), inset 0 -5px 0 rgba(0,0,0,.32), 2px 2px 0 var(--shadow); }
button:disabled { cursor:not-allowed; opacity:.5; filter:grayscale(.35); }
button.primary { background:linear-gradient(#78ff47 0%, #4fd138 48%, #197833 52%, #115022 100%); }
button.large { min-height:74px; font-size:22px; padding:12px; }
.button-title { display:block; font-size:1.05em; }
.button-subtitle { display:block; color:#f3e6ff; font-size:.56em; margin-top:5px; }
input { min-width:0; outline:none; background:#130825; color:var(--ink); border:4px solid var(--outline); padding:12px; box-shadow:inset 4px 4px 0 rgba(0,0,0,.25); }
.app-shell { position:fixed; inset:0; overflow:hidden; }
.menu-screen, .game-screen { width:100%; height:100%; overflow:hidden; position:relative; }
.menu-screen { display:flex; align-items:center; justify-content:center; padding:clamp(10px,2.2vmin,22px); }
.menu-card-xl { width:min(1120px,96vw); height:min(710px,94dvh); padding:clamp(14px,2.3vmin,26px); background:linear-gradient(180deg,#40207c 0%, #27134f 48%, #1a0d35 100%); border:6px solid var(--purple); box-shadow:inset 0 0 0 5px var(--outline), 10px 10px 0 rgba(0,0,0,.38), 0 0 36px rgba(123,80,255,.22); display:grid; grid-template-columns:.95fr 1.35fr; grid-template-rows:auto 1fr auto; gap:clamp(10px,2vmin,18px); overflow:hidden; }
.menu-brand { grid-column:1 / 3; display:flex; align-items:center; justify-content:center; gap:18px; min-height:84px; }
.brand-icon-img { width:72px; height:72px; object-fit:contain; image-rendering:auto; border:5px solid var(--outline); background:#190d35; box-shadow:5px 5px 0 var(--shadow); }
.brand-logo-img { height:86px; max-width:min(720px,78vw); object-fit:contain; filter:drop-shadow(5px 8px 0 #06020c); }
.menu-hero { grid-column:1; grid-row:2; min-height:0; display:grid; grid-template-rows:1fr auto 1fr; place-items:center; gap:12px; padding:16px; background:linear-gradient(180deg, rgba(255,255,255,.07), rgba(0,0,0,.08)); border:5px solid #0a0413; box-shadow:inset 0 0 0 4px rgba(124,85,232,.45); }
.pixel-hero-character { width:58px; height:70px; background:var(--blue); border:5px solid var(--outline); box-shadow:inset 9px 0 rgba(255,255,255,.28), inset -9px 0 rgba(0,0,0,.24), 5px 5px 0 var(--shadow); position:relative; animation:bob 1.1s steps(2,end) infinite; }
.pixel-hero-character.pink { background:var(--pink); animation-delay:.18s; }
.pixel-hero-character::before { content:""; position:absolute; left:16px; top:19px; width:22px; height:24px; background:#fff1bf; border:4px solid var(--outline); }
.pixel-hero-character::after { content:""; position:absolute; left:23px; top:26px; width:5px; height:5px; background:#07101c; box-shadow:10px 0 0 #07101c; }
@keyframes bob { 50% { transform:translateY(-5px); } }
.menu-board-preview { display:grid; grid-template-columns:repeat(3,34px); gap:7px; padding:13px; background:#130825; border:5px solid var(--outline); transform:rotate(-2deg); box-shadow:6px 6px 0 var(--shadow); }
.menu-board-preview span, .menu-board-preview strong, .menu-board-preview i { display:block; width:34px; height:34px; background:#75d446; border:3px solid var(--outline); box-shadow:inset 4px 4px 0 rgba(255,255,255,.22), inset -4px -4px 0 rgba(0,0,0,.18); }
.menu-board-preview strong { background:var(--blue); }
.menu-board-preview i { background:var(--pink); }
.main-menu-stack { grid-column:2; grid-row:2; display:grid; grid-template-columns:1fr 1fr; grid-template-rows:repeat(3,minmax(0,1fr)); gap:clamp(9px,1.5vmin,16px); min-height:0; }
.main-menu-stack > button:nth-child(1) { background:linear-gradient(#75ff48,#43c732 48%,#176a2c 52%,#10491e); }
.main-menu-stack > button:nth-child(2) { background:linear-gradient(#42caff,#2395dd 48%,#145d9d 52%,#10396c); }
.main-menu-stack > button:nth-child(3) { background:linear-gradient(#d65cff,#a33be2 48%,#6920a6 52%,#3f146d); }
.main-menu-stack > button:nth-child(4) { background:linear-gradient(#ff9837,#ef741d 48%,#983a1b 52%,#682515); }
.menu-icon-actions { grid-column:1 / 3; display:grid; grid-template-columns:repeat(3,1fr); gap:clamp(8px,1.5vmin,16px); min-height:0; }
.icon-menu-btn { min-height:72px; background:linear-gradient(#ffe56b,#e8a72d 48%,#9a6212 52%,#5a360d); }
.icon-menu-btn span { display:block; font-size:30px; line-height:1; }
.icon-menu-btn small { display:block; margin-top:5px; font-size:14px; }
.submenu { grid-column:1 / 3; grid-row:2 / 4; width:min(760px,100%); max-height:100%; overflow:auto; margin:auto; text-align:center; background:rgba(10,4,22,.72); border:5px solid #6b44d2; box-shadow:inset 0 0 0 4px var(--outline), 7px 7px 0 var(--shadow); padding:18px; }
.submenu h2 { margin:0 0 14px; color:var(--yellow); font-size:32px; text-shadow:3px 3px 0 var(--shadow); }
.submenu button { width:100%; min-height:58px; margin:8px 0; font-size:18px; }
.hint-text { color:var(--muted); }
.join-row { display:grid; grid-template-columns:1fr auto; gap:8px; }
.stats-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:12px; }
.stats-grid div { background:#130825; border:4px solid var(--outline); padding:12px; }
.stats-grid strong { display:block; color:var(--yellow); font-size:30px; }
.stats-grid span { display:block; color:var(--muted); font-size:13px; }
.settings-row { display:flex; align-items:center; justify-content:center; gap:10px; margin:12px; color:var(--ink); }
.menu-footer { grid-column:1 / 3; text-align:center; color:var(--muted); }
.connection-pill { display:inline-block; border:3px solid var(--purple); background:#140926; padding:6px 12px; }
.game-screen { background:linear-gradient(180deg,#190b36,#080412); }
.game-topbar { height:58px; display:flex; align-items:center; justify-content:space-between; gap:8px; padding:8px 12px; border-bottom:6px solid var(--outline); background:linear-gradient(#3c1f76,#1f0f42); }
.game-mode-label { display:flex; align-items:center; gap:10px; min-width:0; overflow:hidden; }
.topbar-icon-img { width:38px; height:38px; object-fit:contain; border:3px solid var(--outline); background:#180b32; }
.topbar-logo-img { height:36px; width:auto; max-width:220px; object-fit:contain; filter:drop-shadow(3px 4px 0 #05020a); }
.game-mode-label span { color:var(--muted); font-size:14px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.home-icon-button { width:48px; height:42px; min-width:48px; font-size:0; padding:0; position:relative; }
.home-icon-button::before { content:"⌂"; font-size:28px; line-height:1; }
.game-layout { height:calc(100dvh - 58px); padding:10px; display:grid; grid-template-columns:minmax(0,1fr) minmax(330px,410px); gap:12px; overflow:hidden; }
.board-section { position:relative; min-width:0; min-height:0; overflow:hidden; display:flex; align-items:center; justify-content:center; background:linear-gradient(180deg,#201042,#14092b); border:5px solid var(--purple); box-shadow:inset 0 0 0 5px var(--outline), 0 8px 0 rgba(0,0,0,.38); }
#statusStrip, .status-strip { display:none !important; }
#board { display:block; width:min(calc(100% - 16px), calc(100dvh - 92px)); height:min(calc(100% - 16px), calc(100dvh - 92px)); max-width:100%; max-height:100%; image-rendering:auto; }
.turn-panel { min-width:0; min-height:0; display:grid; grid-template-rows:auto 1fr; gap:10px; overflow:hidden; }
.card { min-width:0; background:linear-gradient(180deg,#3b2071,#221145); border:5px solid var(--outline); box-shadow:inset 0 0 0 3px rgba(255,255,255,.08), 5px 5px 0 var(--shadow); padding:12px; }
.card h2 { margin:0 0 8px; color:var(--yellow); font-size:17px; text-transform:uppercase; text-shadow:2px 2px 0 var(--shadow); }
.score-card { min-height:112px; }
.score-value { color:var(--yellow); font-size:54px; line-height:1; text-align:center; text-shadow:4px 4px 0 var(--shadow); }
.score-details { color:var(--muted); font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; text-align:center; }
.turn-card { display:grid; grid-template-rows:auto auto minmax(80px,1fr) auto auto auto; gap:8px; overflow:hidden; }
.turn-mini { min-height:56px; padding:10px; border:4px solid var(--outline); background:#160b2c; color:var(--ink); font-size:15px; line-height:1.25; }
.turn-mini strong { display:block; font-size:18px; }
.turn-mode-text { display:block; margin-top:4px; color:var(--muted); font-size:13px; }
.turn-player-list { display:flex; flex-direction:column; gap:7px; overflow:hidden; min-height:0; }
.player-row { display:grid; grid-template-columns:18px minmax(0,1fr) auto; align-items:center; gap:9px; min-height:40px; padding:8px 10px; background:rgba(7,3,16,.78); border:3px solid var(--outline); color:var(--ink); font-size:18px; }
.player-row.active { border-color:var(--yellow); box-shadow:inset 0 0 0 2px rgba(255,225,90,.25); }
.player-dot { width:14px; height:14px; border:3px solid var(--outline); display:inline-block; }
.player-name { overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.player-meta, .player-wall-count { min-width:44px; color:var(--yellow); text-align:right; font-size:18px; }
.player-wall-count span { display:inline-block; animation:wallPulse 1.1s steps(2,end) infinite; }
@keyframes wallPulse { 50% { transform:translateY(-2px); color:#fff; } }
.players-card, #playersCard { display:none !important; }
.timer-bar { height:10px; border:3px solid var(--outline); background:#090411; overflow:hidden; }
.timer-bar span { display:block; width:100%; height:100%; background:repeating-linear-gradient(90deg,var(--green) 0 18px,var(--yellow) 18px 34px,var(--pink) 34px 50px); }
.mode-toggle { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.mode-toggle button, #rotateWall, #confirmWall { display:block !important; visibility:visible !important; min-height:48px; font-size:16px; }
.mode-toggle button.active { outline:4px solid var(--yellow); }
#rotateWall { background:linear-gradient(#865df0,#4a2990); }
#confirmWall { background:linear-gradient(#43d85d,#16712c); }
#confirmWall:disabled { display:block !important; visibility:visible !important; opacity:.58; }
#cancelWall, .removed-control { display:none !important; }
#resultCard, #compactStatsCard, #settingsCard, #monetizationCard { display:none !important; }

.room-quick-actions {
  display:grid; grid-template-columns:minmax(0,1fr) auto auto; gap:6px; align-items:center;
  padding:7px; border:3px solid var(--yellow); background:#120721; box-shadow:inset 0 0 0 2px rgba(255,225,90,.15);
}
.room-quick-actions[hidden] { display:none !important; }
.room-quick-actions .room-info { min-width:0; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; color:var(--yellow); font-size:13px; }
.room-quick-actions button { min-height:34px; padding:5px 8px; font-size:11px; white-space:nowrap; }
.help-overlay, .match-overlay { position:absolute; inset:0; z-index:10; display:flex; align-items:center; justify-content:center; background:rgba(5,2,10,.72); }
.help-overlay[hidden], .match-overlay[hidden] { display:none !important; }
.help-overlay-card, .match-overlay-card { width:min(520px,92%); background:#291457; border:6px solid var(--purple); box-shadow:inset 0 0 0 5px var(--outline), 8px 8px 0 var(--shadow); padding:20px; text-align:center; }
.overlay-actions { display:flex; gap:12px; justify-content:center; }
.toast { position:absolute; left:50%; bottom:10px; transform:translateX(-50%); min-width:240px; max-width:90%; padding:7px 12px; background:#160b2d; color:var(--ink); border:3px solid var(--blue); text-align:center; opacity:0; pointer-events:none; z-index:20; }
.toast.show { opacity:1; }
.rotate-device-overlay, .mobile-landscape-blocker { display:none !important; }
body.game-start-guard #openMenu { pointer-events: none !important; opacity:.35 !important; }
@media (max-width: 900px) {
  html.touch-device .mode-toggle button, html.touch-device #rotateWall, html.touch-device #confirmWall { min-height:clamp(30px,8vh,44px); padding:4px; font-size:clamp(8px,2.7vh,13px); line-height:1.05; }
  button.large { min-height:58px; font-size:16px; padding:8px; }
  .menu-card-xl { width:100%; height:100%; grid-template-columns:.72fr 1fr; grid-template-rows:auto 1fr auto; gap:10px; padding:12px; }
  .menu-brand { min-height:58px; }
  .brand-icon-img { width:50px; height:50px; }
  .brand-logo-img { height:54px; max-width:70vw; }
  .menu-hero { padding:10px; gap:8px; }
  .pixel-hero-character { width:40px; height:50px; border-width:4px; }
  .pixel-hero-character::before { left:10px; top:13px; width:16px; height:18px; border-width:3px; }
  .menu-board-preview { grid-template-columns:repeat(3,22px); gap:4px; padding:8px; }
  .menu-board-preview span, .menu-board-preview strong, .menu-board-preview i { width:22px; height:22px; }
  .main-menu-stack { grid-template-columns:1fr 1fr; grid-template-rows:repeat(3,minmax(0,1fr)); gap:8px; }
  .button-subtitle { display:none; }
  .menu-icon-actions { gap:8px; }
  .icon-menu-btn { min-height:52px; }
  .icon-menu-btn span { font-size:20px; }
  .icon-menu-btn small { font-size:10px; }
  .menu-footer { display:none; }
  .game-topbar { height:42px; padding:5px 7px; }
  .topbar-icon-img { width:28px; height:28px; }
  .topbar-logo-img { height:27px; max-width:150px; }
  .game-mode-label span { display:none; }
  .home-icon-button { width:38px; min-width:38px; height:32px; }
  .home-icon-button::before { font-size:23px; }
  .game-layout { height:calc(100dvh - 42px); padding:6px; gap:6px; grid-template-columns:70% 30%; }
  .board-section { border-width:4px; }
  #board { width:min(calc(100% - 10px), calc(100dvh - 58px)); height:min(calc(100% - 10px), calc(100dvh - 58px)); }
  .turn-panel { gap:5px; }
  .card { padding:6px; border-width:4px; }
  .score-card { min-height:58px; }
  .score-card h2 { display:none; }
  .score-value { font-size:clamp(24px,8vh,40px); }
  .score-details { font-size:clamp(8px,2.3vh,11px); }
  .turn-card { grid-template-rows:auto auto minmax(64px,1fr) auto auto auto; gap:5px; }
  .turn-card h2 { font-size:clamp(10px,3vh,13px); margin:0; }
  .turn-mini { min-height:34px; padding:6px; font-size:clamp(9px,2.6vh,12px); }
  .turn-mini strong { font-size:clamp(11px,3.1vh,14px); }
  .turn-mode-text { font-size:clamp(8px,2.4vh,11px); }
  .player-row { grid-template-columns:12px minmax(0,1fr) auto; gap:5px; min-height:32px; padding:5px 6px; font-size:clamp(12px,3.2vh,16px); border-width:2px; }
  .player-dot { width:10px; height:10px; border-width:2px; }
  .player-wall-count, .player-meta { min-width:32px; font-size:clamp(12px,3.1vh,16px); }
  .timer-bar { height:8px; border-width:2px; }
  .mode-toggle { gap:5px; }
  .mode-toggle button, #rotateWall, #confirmWall { min-height:clamp(30px,8vh,44px); padding:4px; font-size:clamp(8px,2.7vh,13px); line-height:1.05; }
  .room-quick-actions { grid-template-columns:1fr 1fr; gap:4px; padding:5px; }
  .room-quick-actions .room-info { grid-column:1 / 3; font-size:clamp(9px,2.4vh,12px); text-align:center; }
  .room-quick-actions button { min-height:30px; padding:3px 5px; font-size:clamp(8px,2.2vh,11px); }
}
@media (max-width: 900px) and (orientation: portrait) {
  .menu-screen { padding:8px; align-items:center; }
  .menu-card-xl { width:100%; height:min(78dvh, 660px); grid-template-columns:1fr; grid-template-rows:auto auto 1fr; gap:10px; margin-top:-2dvh; }
  .menu-brand { grid-column:1; min-height:62px; justify-content:flex-start; padding-left:4px; }
  .brand-icon-img { width:52px; height:52px; }
  .brand-logo-img { height:58px; max-width:72vw; }
  .menu-hero { display:none; }
  .main-menu-stack { grid-column:1; grid-row:3; height:100%; grid-template-columns:1fr 1fr; grid-template-rows:repeat(3, minmax(0,1fr)); }
  .main-menu-stack > button { min-height:0; height:100%; }
  .submenu { grid-column:1; grid-row:2 / 4; width:100%; height:100%; }
  .game-layout { height:calc(100dvh - 42px); grid-template-columns:1fr; grid-template-rows:minmax(0,1fr) minmax(210px,36dvh); gap:6px; }
  #board { width:min(calc(100vw - 22px), calc(64dvh - 54px)); height:min(calc(100vw - 22px), calc(64dvh - 54px)); }
  .turn-panel { grid-template-columns:88px minmax(0,1fr); grid-template-rows:1fr; gap:6px; }
  .score-card { min-height:0; }
  .turn-card { min-height:0; }
  .score-value { font-size:28px; writing-mode:horizontal-tb; }
  .score-details { white-space:normal; }
  .turn-mini { min-height:32px; }
}


/* Boot safety: the HTML appears before the ES module finishes attaching controls.
   Keep early taps from landing on inert buttons, especially on mobile Safari. */
body.is-booting button,
body.is-booting input {
  pointer-events: none !important;
  opacity: 0.55;
}
body.is-booting .connection-pill::after {
  content: ' · Loading';
}

/* Final mobile touch fix: canvas gestures must not pan/zoom the page and must
   be mapped directly to the real portrait canvas rectangle. */
.board-section,
#board {
  touch-action: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
}

/* v0.2 retention and release polish */
.profile-chip {
  margin-left:auto; min-width:150px; padding:8px 10px; background:#16092d;
  border:4px solid var(--outline); box-shadow:4px 4px 0 var(--shadow); text-align:left;
}
.profile-chip strong { display:block; color:var(--yellow); font-size:16px; }
.profile-chip span { display:block; color:var(--muted); font-size:11px; margin:3px 0 5px; }
.profile-chip i { display:block; height:8px; overflow:hidden; border:2px solid var(--outline); background:#080311; }
.profile-chip b { display:block; width:0; height:100%; background:linear-gradient(90deg,var(--green),var(--yellow)); transition:width .35s steps(6,end); }
.menu-icon-actions { grid-template-columns:repeat(4,1fr); }
.daily-menu-btn { position:relative; background:linear-gradient(#ff78ba,#dc3b8f 48%,#8f215d 52%,#5a133c) !important; }
.daily-menu-btn em { position:absolute; top:-7px; right:-7px; min-width:25px; height:25px; display:grid; place-items:center; border:3px solid var(--outline); border-radius:50%; background:var(--yellow); color:#2d1230; font-style:normal; font-size:11px; text-shadow:none; }
.bot-difficulty-row { flex-wrap:wrap; }
.bot-difficulty-row select { min-width:150px; border:3px solid var(--outline); background:#16092d; color:var(--ink); padding:8px; font:inherit; }
.stats-profile-line { display:flex; flex-wrap:wrap; justify-content:center; gap:8px; margin-bottom:12px; }
.stats-profile-line span,.stats-profile-line strong { background:#16092d; border:3px solid var(--outline); padding:7px 10px; }
.stats-profile-line strong { color:var(--yellow); }
.achievement-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:8px; margin:12px 0; }
.achievement { min-height:56px; padding:8px; border:3px solid var(--outline); background:#130825; text-align:left; opacity:.45; }
.achievement.unlocked { opacity:1; border-color:var(--yellow); box-shadow:inset 0 0 0 2px rgba(255,223,77,.2); }
.achievement strong { display:block; color:var(--yellow); font-size:13px; }
.achievement span { display:block; color:var(--muted); font-size:10px; margin-top:3px; }
.mission-chip { padding:7px 8px; border:3px solid var(--outline); background:linear-gradient(90deg,#4c1c74,#241144); color:#fff; font-size:12px; line-height:1.25; }
.mission-chip strong { color:var(--yellow); }
.result-card #shareResult,.match-overlay #overlayShare { background:linear-gradient(#42caff,#246db6); }
.match-overlay-card { position:relative; overflow:hidden; }
.victory-fx { position:absolute; inset:0; pointer-events:none; z-index:15; overflow:hidden; display:none; }
.victory-fx.active { display:block; }
.victory-fx i { position:absolute; top:-24px; width:10px; height:16px; background:var(--yellow); border:2px solid var(--outline); animation:confettiFall 1.8s linear forwards; }
.victory-fx i:nth-child(3n) { background:var(--pink); }
.victory-fx i:nth-child(3n+1) { background:var(--blue); }
@keyframes confettiFall { to { transform:translateY(110dvh) rotate(540deg); } }
body.impact-shake .board-section { animation:impactShake .24s steps(2,end); }
@keyframes impactShake { 25%{transform:translateX(-4px)} 50%{transform:translateX(4px)} 75%{transform:translateX(-2px)} }

@media (max-width:900px) {
  .profile-chip { min-width:112px; padding:5px 7px; }
  .profile-chip strong { font-size:12px; }
  .profile-chip span { font-size:8px; }
  .menu-icon-actions { grid-template-columns:repeat(4,1fr); }
  .icon-menu-btn { min-width:0; padding:4px; }
  .daily-menu-btn em { min-width:20px; height:20px; font-size:9px; }
  .mission-chip { font-size:clamp(8px,2.3vh,11px); padding:4px 5px; }
  .achievement-grid { grid-template-columns:1fr; }
}
@media (max-width:900px) and (orientation:portrait) {
  .menu-brand { justify-content:flex-start; }
  .profile-chip { margin-left:auto; }
  .game-layout { grid-template-rows:minmax(0,1fr) minmax(230px,38dvh); }
  .turn-card { grid-template-rows:auto auto minmax(58px,1fr) auto auto auto auto; }
  .turn-player-list { max-height:92px; overflow:auto; }
}

/* Release-candidate responsive hardening. Keep mobile menu labels and icon
   actions inside their grid tracks instead of letting min-content widths clip. */
.main-menu-stack,
.menu-icon-actions { min-width: 0; width: 100%; }
.main-menu-stack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.menu-icon-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.main-menu-stack > button,
.menu-icon-actions > button { min-width: 0; overflow: hidden; }
.main-menu-stack .button-title,
.icon-menu-btn small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-icon-img,
.brand-logo-img,
.topbar-icon-img,
.topbar-logo-img { image-rendering: pixelated; }

/* CrazyGames App safe-area support for notches, rounded corners and dynamic islands. */
.menu-screen {
  padding-top: max(clamp(10px,2.2vmin,22px), env(safe-area-inset-top));
  padding-right: max(clamp(10px,2.2vmin,22px), env(safe-area-inset-right));
  padding-bottom: max(clamp(10px,2.2vmin,22px), env(safe-area-inset-bottom));
  padding-left: max(clamp(10px,2.2vmin,22px), env(safe-area-inset-left));
}
.game-topbar {
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
  padding-top: max(8px, env(safe-area-inset-top));
}
.game-layout {
  padding-right: max(10px, env(safe-area-inset-right));
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  padding-left: max(10px, env(safe-area-inset-left));
}

@media (max-width: 900px) {
  .main-menu-stack > button { font-size: clamp(12px, 3.8vw, 16px); padding-inline: 4px; }
  .menu-icon-actions > button { padding-inline: 2px; }
  .icon-menu-btn small { font-size: clamp(8px, 2.4vw, 10px); }
  .game-topbar {
    padding-left: max(7px, env(safe-area-inset-left));
    padding-right: max(7px, env(safe-area-inset-right));
    padding-top: max(5px, env(safe-area-inset-top));
  }
  .game-layout {
    padding-right: max(6px, env(safe-area-inset-right));
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    padding-left: max(6px, env(safe-area-inset-left));
  }
}

@media (max-width: 430px) and (orientation: portrait) {
  .menu-card-xl { padding: 9px; }
  .menu-brand { gap: 8px; }
  .brand-icon-img { width: 46px; height: 46px; }
  .brand-logo-img { height: 49px; max-width: 52vw; }
  .profile-chip { min-width: 88px; max-width: 92px; }
  .main-menu-stack { gap: 6px; }
  .menu-icon-actions { gap: 5px; }
  .main-menu-stack > button { font-size: 12px; letter-spacing: 0; }
  .icon-menu-btn span { font-size: 18px; }
  .icon-menu-btn small { font-size: 8px; letter-spacing: 0; }
}

/* Private-room code entry: native text fields must override the game's global
   no-selection gesture policy. This is required in embedded Chromium/WebKit
   where inherited -webkit-user-select:none can prevent focus/keyboard input. */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.menu-join-row {
  position: relative;
  isolation: isolate;
  overflow: visible;
}
.menu-join-row input,
#roomCode {
  position: relative;
  z-index: 2;
  pointer-events: auto !important;
  touch-action: auto !important;
  user-select: text !important;
  -webkit-user-select: text !important;
  -webkit-touch-callout: default !important;
  caret-color: var(--yellow);
  cursor: text;
  text-transform: uppercase;
}
#roomCode:focus {
  border-color: var(--yellow);
  outline: 3px solid rgba(255, 223, 77, .35);
  box-shadow: inset 4px 4px 0 rgba(0,0,0,.25), 0 0 0 3px var(--outline);
}
.menu-join-row #joinRoom {
  position: relative;
  z-index: 1;
  width: auto;
  min-width: 112px;
  margin: 0;
}
body.room-code-entry-active {
  touch-action: auto;
}
@media (max-width: 520px) {
  .menu-join-row { grid-template-columns: minmax(0, 1fr) 92px; }
  .menu-join-row input { min-width: 0; font-size: 16px; }
  .menu-join-row #joinRoom { min-width: 0; font-size: 14px; padding-inline: 6px; }
}
