* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1b2545; font-family: "Arial Rounded MT Bold", Nunito, Verdana, sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* fixed: no rubber-band scrolling of the page on iOS; the canvas fills the visible area (app.js sets its exact size
   from the visual viewport: 100vh is taller than what's visible on iOS) */
body { position: fixed; inset: 0; }
canvas { display: block; position: fixed; left: 0; top: 0; width: 100%; height: 100%; }
body.kid canvas, body.both canvas { cursor: none; }
.hidden { display: none !important; }
/* Overlays scroll on small screens; `margin: auto` centers their content when it fits. */
.overlay { position: fixed; inset: 0; display: flex; overflow-y: auto; padding: 12px 0; background: #1b2545ee; z-index: 10; touch-action: pan-y; }
.overlay > * { margin: auto; }
.overlay.top { z-index: 30; }
.panel { background: #fff8ec; border-radius: 32px; padding: clamp(18px, 4vw, 32px) clamp(16px, 5vw, 40px); max-width: 980px; width: calc(100vw - 32px); text-align: center; box-shadow: 0 20px 60px #0008; user-select: text; -webkit-user-select: text; }
h2 { margin: 6px 0 14px; font-size: clamp(24px, 5vw, 36px); color: #1b2545; line-height: 1.25; }
h1 { margin: 0 0 4px; font-size: 44px; color: #ff6b6b; }
.sub { margin: 0 0 20px; color: #555; font-size: 20px; }
.roles { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }
.role { flex: 1 1 240px; display: flex; flex-direction: column; gap: 6px; padding: 22px; border-radius: 22px; background: #ffe8a3; color: #333; text-decoration: none; border: 4px solid transparent; transition: transform .1s; }
.role:hover, .role:focus-visible { transform: scale(1.04); border-color: #ff9f1c; outline: none; }
.role:active { transform: scale(.98); }
.role.off { background: #eee6d8; }
.role.off small { color: #a33; font-weight: bold; }
.role.off span { filter: grayscale(1); opacity: .6; }
.role span { font-size: 54px; }
@media (max-width: 560px) { /* phones: tiles in a column, emoji beside the text */
  .roles { gap: 12px; }
  .role { flex: 1 1 100%; display: grid; grid-template-columns: 64px 1fr; grid-template-rows: auto auto; column-gap: 12px; text-align: left; padding: 16px; }
  .role span { grid-row: span 2; font-size: 46px; align-self: center; text-align: center; }
  h1 { font-size: 34px; }
}
.role b { font-size: 24px; }
.role small { color: #666; font-size: 15px; }
.urls { color: #666; font-size: 15px; margin: 18px 0 0; line-height: 1.6; }
.urls code { background: #eee; padding: 2px 8px; border-radius: 6px; color: #333; }
#startBtn { width: 300px; height: 300px; border-radius: 50%; border: 0; font-size: 150px; color: #fff; background: #2ec4b6; box-shadow: 0 12px 0 #1a9488, 0 20px 50px #0008;
  cursor: pointer; animation: pulse 1.2s ease-in-out infinite; padding-left: 40px; }
@keyframes pulse { 50% { transform: scale(1.08); } }
#hud { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 18px; align-items: center; padding: 6px 14px; background: #000a; color: #fff; font-size: 15px; font-family: Verdana, sans-serif; z-index: 5; }
body.both #hud { font-size: 12px; padding: 3px 10px; background: #0006; }
#hudTitle { font-weight: bold; white-space: nowrap; }
#hudKeys { flex: 1; color: #ddd; }
#hudKeys kbd { background: #fff2; border: 1px solid #fff5; border-radius: 4px; padding: 0 5px; margin: 0 3px 0 8px; color: #fff; font-family: inherit; }
#hudRight { display: flex; gap: 8px; align-items: center; white-space: nowrap; }
#hud button { font-size: 16px; background: #fff2; border: 1px solid #fff4; border-radius: 6px; color: #fff; cursor: pointer; padding: 1px 6px; }
#hud button.off { opacity: .35; }
#conn { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); background: #ff6b6b; color: #fff; padding: 6px 16px; border-radius: 20px; z-index: 20; font-family: Verdana, sans-serif; }

/* Big, touch-friendly buttons for the start / join / allow screens */
.buttons { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin: 18px 0 4px; }
.big, .mid { border: 0; border-radius: 22px; font-family: inherit; font-weight: bold; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; touch-action: manipulation; }
.big { font-size: 30px; min-height: 76px; min-width: 200px; padding: 14px 36px; }
.mid { font-size: 20px; min-height: 52px; padding: 8px 24px; border-radius: 16px; }
.go { background: #2ec4b6; color: #fff; box-shadow: 0 6px 0 #1a9488; }
.ghost { background: #e6ddd0; color: #333; box-shadow: 0 6px 0 #c4b8a6; }
.big:active, .mid:active { transform: translateY(4px); box-shadow: 0 2px 0 #0003; }
.big:focus-visible, .mid:focus-visible, #codeInput:focus-visible { outline: 5px solid #ff9f1c; outline-offset: 4px; }
.big:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 8px; color: #555; font: inherit; font-size: 15px; text-decoration: underline; cursor: pointer; }
.msg { color: #c0392b; font-size: 20px; min-height: 1.3em; margin: 12px 0 0; font-weight: bold; }
.msg:empty { min-height: 0; margin: 0; }
.bigEmoji { font-size: 72px; line-height: 1.1; }
.spin { animation: tip 2s ease-in-out infinite; }
@keyframes tip { 50% { transform: rotate(180deg); } }

#codeInput { display: block; margin: 8px auto 0; width: 100%; max-width: 6em; font-size: min(110px, 20vw); font-weight: bold; text-align: center;
  letter-spacing: .2em; text-indent: .2em; text-transform: uppercase; color: #1b2545; background: #fff; border: 5px solid #ffd166; border-radius: 26px;
  padding: 4px 0; font-family: inherit; user-select: text; -webkit-user-select: text; touch-action: manipulation; }
#codeInput::placeholder { color: #ddd; }

/* The room code on the grown-up's screen: big, top right, above the "tap to start" button */
#room { position: fixed; top: 12px; right: 12px; z-index: 15; width: min(420px, calc(100vw - 24px)); background: #fff8ec; border-radius: 26px;
  padding: 14px 20px 16px; text-align: center; box-shadow: 0 14px 40px #0009; border: 5px solid #ffd166; user-select: text; -webkit-user-select: text; }
.roomLabel { font-size: 18px; color: #666; font-weight: bold; text-transform: uppercase; letter-spacing: .1em; }
.roomCode { font-size: min(108px, 22vw); font-weight: bold; letter-spacing: .14em; text-indent: .14em; color: #1b2545; line-height: 1.05; font-family: "Arial Rounded MT Bold", Verdana, sans-serif; }
.roomHow { font-size: 17px; color: #444; margin: 6px 0 0; line-height: 1.45; font-family: Verdana, sans-serif; }
.roomHow b { color: #1b2545; overflow-wrap: anywhere; }
.roomHint { font-size: 13px; color: #777; margin: 4px 0 0; font-family: Verdana, sans-serif; }
.roomHint:empty { display: none; }
#room .msg { font-size: 16px; }
#room .mid { margin-top: 10px; }
#hud #hudNew { font-size: 13px; padding: 2px 8px; }
#conn { display: flex; flex-direction: column; align-items: center; text-align: center; }
#conn .link { color: #fff; font-size: 13px; padding: 4px 4px 0; }

/* "Turn your device sideways": a phone that rotates, over the game (which keeps running underneath) */
#turn { position: fixed; inset: 0; z-index: 12; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4vh;
  background: #1b2545f2; pointer-events: auto; }
.turnPhone { width: 34vw; max-width: 200px; aspect-ratio: 9 / 17; border-radius: 28px; background: #ffd166; padding: 14px 10px; box-shadow: 0 16px 40px #0008;
  animation: turnIt 2.4s ease-in-out infinite; }
.turnScreen { width: 100%; height: 100%; border-radius: 16px; background: #bde0fe; display: flex; align-items: center; justify-content: center; font-size: min(18vw, 110px); }
.turnArrow { font-size: min(22vw, 120px); color: #ffd166; line-height: 1; font-family: Verdana, sans-serif; animation: pulse 1.2s ease-in-out infinite; }
@keyframes turnIt { 0%, 20% { transform: rotate(0deg); } 55%, 85% { transform: rotate(90deg); } 100% { transform: rotate(0deg); } }

/* the safe area (notch, home bar) */
#hud { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); padding-bottom: max(6px, env(safe-area-inset-bottom)); }
#room { top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); }
/* Phones in landscape (short screens): a compact room code card so most of the game stays visible */
@media (max-height: 500px) {
  #room { width: min(300px, calc(100vw - 24px)); padding: 6px 12px 8px; border-width: 4px; border-radius: 18px; top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); }
  .roomLabel { font-size: 12px; }
  .roomCode { font-size: 54px; }
  .roomHow { font-size: 13px; margin-top: 2px; line-height: 1.3; }
  .roomHint { font-size: 11px; }
  #startBtn { width: 200px; height: 200px; font-size: 100px; padding-left: 26px; }
  .bigEmoji { font-size: 48px; }
  .big { font-size: 24px; min-height: 60px; }
  #codeInput { font-size: 64px; }
  h1 { font-size: 30px; }
  .sub { font-size: 17px; margin-bottom: 8px; }
  .buttons { margin-top: 10px; }
}
