* { 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, h2.title { margin: 0 0 4px; font-size: 44px; color: #e0474a; line-height: 1.2; }
.sub { margin: 0 0 20px; color: #555; font-size: 20px; }
/* Start screen tiles: "Play together here" first and biggest, then "Play alone", then the two-device pair (smaller) */
.roles { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }
.role { flex: 1 1 calc(50% - 18px); 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; touch-action: manipulation; }
.role:hover, .role:focus-visible { transform: scale(1.04); border-color: #ff9f1c; outline: none; }
.role:active { transform: scale(.98); }
.role span { font-size: 54px; }
.role b { font-size: 24px; }
.role small { color: #666; font-size: 15px; }
.role.main { flex: 3 1 340px; background: #0e7f74; color: #fff; box-shadow: 0 6px 0 #095a52; }
.role.main b { font-size: 30px; }
.role.main small { color: #e6fffb; font-size: 16px; }
.roles > .role:not(.main) { flex: 2 1 240px; }
.pairHead { margin: 22px 0 8px; color: #666; font-size: 16px; font-weight: bold; }
.pair { gap: 12px; }
.roles.pair > .role { flex: 1 1 240px; display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto; align-content: center; column-gap: 10px; text-align: left; padding: 10px 14px; background: #f1e8da; min-height: 64px; }
.pair .role span { grid-row: span 2; font-size: 34px; align-self: center; text-align: center; }
.pair .role b { font-size: 19px; }
.pair .role small { font-size: 14px; }
.role.off { background: #eee6d8 !important; }
.role.off small { color: #a33; font-weight: bold; }
.role.off span { filter: grayscale(1); opacity: .6; }
@media (max-height: 520px) and (min-width: 561px) { /* phones held sideways: short tiles, emoji beside the text */
  .roles { gap: 10px; }
  .role { display: grid; grid-template-columns: 56px 1fr; grid-template-rows: auto auto; align-content: center; column-gap: 12px; text-align: left; padding: 10px 16px; min-height: 64px; }
  .role span { grid-row: span 2; font-size: 40px; align-self: center; text-align: center; }
  .role.main b { font-size: 24px; }
  .role.main small { font-size: 14px; }
  .pairHead { margin: 12px 0 6px; font-size: 14px; }
  .roles.pair > .role { min-height: 56px; padding: 6px 12px; }
  .pair .role span { font-size: 28px; }
  h1, h2.title { font-size: 30px; }
}
@media (max-width: 560px) { /* phones: tiles in a column, emoji beside the text */
  .roles { gap: 12px; }
  .roles > .role, .roles > .role:not(.main), .roles.pair > .role { flex: 1 1 100%; display: grid; grid-template-columns: 56px 1fr; grid-template-rows: auto auto; align-content: center; column-gap: 12px; text-align: left; padding: 14px 16px; min-height: 64px; }
  .role span { grid-row: span 2; font-size: 44px; align-self: center; text-align: center; }
  .role.main b { font-size: 23px; }
  .roles.pair > .role { grid-template-columns: 44px 1fr; padding: 10px 14px; min-height: 56px; }
  .pair .role span { font-size: 32px; }
  .pairHead { margin: 18px 0 8px; }
  h1, h2.title { font-size: 34px; }
  .sub { font-size: 18px; margin-bottom: 14px; }
}
/* The start screen at "/" (html.landing; the app screens' copies drop the class, server/site.js appPage()): an
   ordinary page that scrolls and zooms, with nothing fixed, so it reads the same to people, screen readers and crawlers.
   The app screens keep the fixed, no-zoom canvas page above. */
html.landing, html.landing body { height: auto; overflow: visible; position: static; touch-action: auto; overscroll-behavior: auto;
  user-select: auto; -webkit-user-select: auto; -webkit-touch-callout: default; }
html.landing canvas { display: none; }
html.landing #home { position: static; min-height: 100vh; min-height: 100dvh; overflow: visible; touch-action: auto; background: #1b2545; }
.noscript { margin: 16px auto 0; max-width: 640px; padding: 10px 16px; border-radius: 14px; background: #ffe8a3; color: #333; font: 16px/1.45 Verdana, sans-serif; }
/* Landing text under the start buttons (index.html #home .about) */
.about { text-align: left; margin: 28px auto 0; max-width: 760px; color: #333; font-family: Verdana, sans-serif; font-size: 17px; line-height: 1.55; }
.about h2 { margin: 30px 0 10px; font-size: clamp(22px, 4vw, 28px); font-family: "Arial Rounded MT Bold", Nunito, Verdana, sans-serif; }
.about p { margin: 0 0 12px; }
.about h3 { margin: 18px 0 4px; font-size: 19px; color: #1b2545; line-height: 1.35; font-family: "Arial Rounded MT Bold", Nunito, Verdana, sans-serif; }
.about .faq a { color: #0b6e99; }
.about ul { list-style: none; margin: 0; padding: 0; }
.points li { margin: 0 0 8px; padding-left: 26px; position: relative; }
.points li::before { content: "★"; position: absolute; left: 0; color: #ff9f1c; }
.gamelist { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.gamelist li { display: flex; }
.gamelist a { flex: 1; display: flex; gap: 12px; align-items: flex-start; background: #fff; border-radius: 18px; padding: 12px 14px; color: inherit;
  text-decoration: none; border: 3px solid transparent; transition: transform .1s, border-color .1s; }
.gamelist a:hover, .gamelist a:focus-visible { border-color: #ff9f1c; transform: translateY(-2px); outline: none; }
.gamelist a:hover b, .gamelist a:focus-visible b { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.gamelist span { font-size: 38px; line-height: 1.1; }
.gamelist b { display: block; font-size: 18px; color: #1b2545; }
.gamelist em { display: block; font-style: normal; font-size: 14px; color: #a05a00; margin: 2px 0 4px; }
.gamelist p { margin: 0; font-size: 15px; color: #555; }
.urls { color: #666; font-size: 15px; margin: 18px 0 0; line-height: 1.6; }
.about .skills { margin: 0 0 14px; font-size: 16px; line-height: 1.9; }
footer.urls a, .about .skills a { color: #0b6e99; font-weight: normal; white-space: nowrap; }
.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, h2.title { font-size: 30px; }
  .sub { font-size: 17px; margin-bottom: 8px; }
  .buttons { margin-top: 10px; }
}

/* ---- The grown-up's on-screen pad (public/touch-pad.js): only on phones / tablets, never over the game ---- */
body.padOn #hud { display: none !important; } /* the pad replaces the key-help bar (and its ☰ menu has 🔊 🎵) */
#pad { position: fixed; inset: 0; z-index: 6; pointer-events: none; font-family: Verdana, sans-serif; }
#pad > * { position: fixed; touch-action: none; -webkit-user-select: none; user-select: none; }
.pdArea { pointer-events: auto; border-radius: 22px; }
.pdArm { display: flex; align-items: center; justify-content: center; background: #ffffff2e; border: 2px solid #ffffff55; color: #fff;
  font-size: 20px; border-radius: 12px; pointer-events: none; }
.pdArm.on { background: #ffd166; color: #1b2545; border-color: #ffd166; }
.pdCap { color: #fffc; font-size: 12px; text-align: center; pointer-events: none; overflow: hidden; line-height: 1.2; }
.pbtn { pointer-events: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: #ffffff26; border: 2px solid #ffffff55; border-radius: 18px; color: #fff; text-align: center; overflow: hidden; cursor: pointer;
  box-shadow: 0 4px 0 #0005; --s: 80px; }
.pbtn.on, .pbtn:active { background: #ffd166; color: #1b2545; border-color: #ffd166; transform: translateY(2px); box-shadow: 0 2px 0 #0005; }
.pbtn.pbig { background: #2ec4b6aa; border-color: #2ec4b6; }
.pIcon { font-size: calc(var(--s) * .36); line-height: 1; font-weight: bold; }
.pText { font-size: clamp(10px, calc(var(--s) * .15), 15px); line-height: 1.1; padding: 0 3px; max-height: 2.3em; overflow: hidden; }
.pbtn.tiny .pText { font-size: 10px; max-height: 1.15em; }
.pmenu { background: #0000; border-style: dashed; position: fixed; }
.pRing { position: absolute; inset: 0; border-radius: 16px; background: #ffd16688; transform: scaleY(0); transform-origin: bottom; pointer-events: none; }
.pmenu.holding .pRing { transform: scaleY(1); transition: transform .7s linear; }
.pkb.on { background: #ffd166; color: #1b2545; }
.pSheet { pointer-events: auto; display: flex; gap: 8px; padding: 8px; background: #1b2545ee; border-radius: 20px; box-shadow: 0 -6px 30px #0008; z-index: 7; }
.pSheet .pbtn { position: static; flex: none; --s: 72px; }
.pSheet .pIcon { font-size: 34px; }
#padInput { position: fixed; left: 0; top: 0; width: 2px; height: 2px; opacity: 0; border: 0; padding: 0; resize: none; font-size: 16px; /* 16px: no iOS zoom */
  color: transparent; background: transparent; caret-color: transparent; z-index: 0; -webkit-user-select: text; user-select: text; }
#padMenu .padPanel { max-width: 640px; }
#padMenu h2 { font-size: clamp(18px, 4vw, 26px); margin-bottom: 6px; }
#padMenu .sub { margin-bottom: 10px; font-size: 15px; }
.padItems { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.padItems .mid { min-height: 60px; font-size: 19px; gap: 8px; }
.padItems .mid span { font-size: 26px; }
#padMenu .buttons { margin-top: 12px; }
#padMenu .big { min-height: 56px; font-size: 22px; }
#padToast { position: fixed; z-index: 8; background: #000c; color: #fff; padding: 8px 12px; border-radius: 12px; font: 14px Verdana, sans-serif; max-width: 260px; pointer-events: none; }
@media (max-height: 500px) { #padMenu .panel { padding: 12px 16px; } .padItems .mid { min-height: 48px; font-size: 16px; } }
