* { margin: 0; padding: 0; box-sizing: border-box; }
.hidden { display: none !important; }
:root {
  --paper: #f2ede2;
  --ink: #1a1713;
  --red: #d9422b;
}
html, body { height: 100%; background: #d8d2c2; overflow: hidden; }
body { font-family: Georgia, 'Times New Roman', serif; color: var(--ink); display: flex; align-items: center; justify-content: center; }

#app { position: relative; }
canvas#game { display: block; background: var(--paper); box-shadow: 14px 14px 0 rgba(26,23,19,0.28); }

.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--paper); z-index: 10; }
.overlay.hidden { display: none; }
.menu-inner { text-align: center; padding: 24px; max-width: 640px; }

.title {
  font-family: 'Arial Black', 'Helvetica Neue', sans-serif;
  font-size: 110px; font-weight: 900; letter-spacing: 8px; margin-left: 8px;
  color: var(--ink); position: relative; display: inline-block; line-height: 1;
  text-shadow: 5px 5px 0 var(--red);
}
.tagline { color: var(--ink); margin-top: 14px; font-size: 19px; font-style: italic; }
.how { color: #57503f; margin: 20px auto 30px; font-size: 15px; line-height: 1.65; max-width: 420px; }
.how em { color: var(--red); font-style: normal; font-weight: bold; }
.label { color: #57503f; letter-spacing: 5px; font-size: 13px; text-transform: uppercase; font-family: 'Arial Black', sans-serif; }
.code {
  font-family: 'Arial Black', sans-serif;
  font-size: 84px; letter-spacing: 16px; margin: 12px 0 8px; margin-left: 16px;
  color: var(--red); user-select: all; text-shadow: 4px 4px 0 var(--ink);
}

.menu-buttons { display: flex; flex-direction: column; gap: 14px; align-items: center; }
button {
  background: var(--paper); color: var(--ink);
  border: 3px solid var(--ink); padding: 14px 40px; font-size: 17px;
  letter-spacing: 3px; cursor: pointer; transition: all .1s;
  font-family: 'Arial Black', 'Helvetica Neue', sans-serif; font-weight: 900;
  box-shadow: 5px 5px 0 var(--ink);
}
button:hover { background: var(--ink); color: var(--paper); box-shadow: 5px 5px 0 var(--red); transform: translate(-1px,-1px); }
button:active { transform: translate(3px,3px); box-shadow: 2px 2px 0 var(--ink); }
button.small { padding: 9px 24px; font-size: 13px; }
button:disabled { opacity: 0.5; cursor: wait; transform: none; }
#howTo {
  margin: 0 auto 22px; max-width: 460px; text-align: left;
  border: 3px solid var(--ink); background: var(--paper);
  box-shadow: 5px 5px 0 rgba(26,23,19,0.3); padding: 12px 16px; font-size: 14px; line-height: 1.6;
}
#howTo summary { cursor: pointer; font-family: 'Arial Black', sans-serif; font-size: 12px; letter-spacing: 2px; }
#howTo ol { margin: 10px 0 4px 20px; }
#howTo li { margin-bottom: 8px; }
.roomhelp { color: #57503f; font-size: 14px; font-style: italic; max-width: 420px; margin: 10px auto 18px; line-height: 1.6; }
.room-buttons { display: flex; gap: 12px; justify-content: center; }
.join-row { display: flex; gap: 12px; }
#joinCode {
  background: var(--paper); border: 3px solid var(--ink); color: var(--red);
  font-size: 26px; letter-spacing: 10px; width: 170px; text-align: center;
  text-transform: uppercase; border-radius: 0; padding: 8px;
  font-family: 'Arial Black', sans-serif; font-weight: 900; box-shadow: inset 3px 3px 0 rgba(26,23,19,0.08);
}
#joinCode:focus { outline: 3px solid var(--red); outline-offset: 2px; }
.error { color: var(--red); min-height: 24px; margin-top: 14px; font-size: 14px; font-weight: bold; }
.controls-card {
  margin-top: 30px; color: #57503f; font-size: 13.5px; line-height: 2;
  border-top: 3px solid var(--ink); padding-top: 18px;
}
.controls-card b { color: var(--ink); font-family: 'Arial Black', sans-serif; font-size: 12px; letter-spacing: 1px; }
#touchHint b { color: var(--red); }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }

/* HUD */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#hud.hidden { display: none; }
#objective {
  position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: var(--paper); border: 3px solid var(--ink); padding: 7px 18px;
  font-size: 14px; font-weight: bold; color: var(--ink); max-width: 58%; text-align: center;
  box-shadow: 4px 4px 0 rgba(26,23,19,0.85); line-height: 1.4;
}
#hudRight { position: absolute; top: 16px; right: 16px; display: flex; gap: 10px; font-size: 11px; color: var(--ink); align-items: center; }
#playerTag { font-family: 'Arial Black', sans-serif; letter-spacing: 1px; }
#levelTag {
  border: 2px solid var(--ink); padding: 3px 10px; background: var(--paper);
  font-family: 'Arial Black', sans-serif; letter-spacing: 1px; box-shadow: 3px 3px 0 rgba(26,23,19,0.3);
}
#blinkChip {
  position: absolute; bottom: 16px; left: 16px; width: 96px; height: 32px;
  background: var(--paper); border: 2.5px solid var(--ink); overflow: hidden;
  box-shadow: 4px 4px 0 rgba(26,23,19,0.3);
}
#blinkFill { position: absolute; inset: 0; width: 100%; background: var(--red); opacity: .85; transition: width .1s linear; }
#blinkLabel { position: relative; z-index: 1; display: block; text-align: center; line-height: 27px; font-size: 11px; letter-spacing: 3px; color: var(--ink); font-family: 'Arial Black', sans-serif; }
#phaseChip {
  position: absolute; bottom: 58px; left: 16px;
  background: var(--paper); border: 2.5px solid var(--ink); padding: 5px 12px;
  font-family: 'Arial Black', sans-serif; font-size: 12px; letter-spacing: 2px;
  box-shadow: 4px 4px 0 rgba(26,23,19,0.3);
}
#phaseChip.hidden { display: none; }
#btnSwitch {
  position: absolute; bottom: 16px; left: 128px; pointer-events: auto;
  padding: 7px 16px; font-size: 12px; letter-spacing: 2px;
  box-shadow: 4px 4px 0 rgba(26,23,19,0.3);
}
#btnSwitch.hidden { display: none; }
#controlsHint { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); font-size: 11px; color: #57503f; font-style: italic; white-space: nowrap; }
#interactPrompt {
  position: absolute; bottom: 82px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); font-size: 14px; padding: 7px 18px;
  border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--red); font-family: 'Arial Black', sans-serif; letter-spacing: 1px;
}
#toast {
  position: absolute; bottom: 128px; left: 50%; transform: translateX(-50%);
  background: var(--red); color: var(--paper); padding: 7px 20px; font-size: 13.5px;
  border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); font-weight: bold;
}
#btnLeave2 {
  position: absolute; top: 12px; left: 12px; pointer-events: auto;
  background: var(--paper); border: 2.5px solid var(--ink); color: var(--ink);
  width: 32px; height: 32px; padding: 0; font-size: 13px; box-shadow: 3px 3px 0 rgba(26,23,19,0.5);
}
#btnHelp {
  position: absolute; top: 12px; left: 52px; pointer-events: auto;
  background: var(--paper); border: 2.5px solid var(--ink); color: var(--ink);
  width: 32px; height: 32px; padding: 0; font-size: 15px; box-shadow: 3px 3px 0 rgba(26,23,19,0.5);
}
#btnMute {
  position: absolute; top: 12px; left: 92px; pointer-events: auto;
  background: var(--paper); border: 2.5px solid var(--ink); color: var(--ink);
  width: 32px; height: 32px; padding: 0; font-size: 14px; box-shadow: 3px 3px 0 rgba(26,23,19,0.5);
}
#btnPause {
  position: absolute; top: 12px; left: 132px; pointer-events: auto;
  background: var(--paper); border: 2.5px solid var(--ink); color: var(--ink);
  width: 32px; height: 32px; padding: 0; font-size: 13px; box-shadow: 3px 3px 0 rgba(26,23,19,0.5);
}
#pauseOverlay { background: rgba(242,237,226,0.93); z-index: 14; }
#pauseOverlay.hidden { display: none; }
#helpOverlay { background: rgba(242,237,226,0.96); z-index: 12; }
#helpOverlay.hidden { display: none; }
.help-card {
  background: var(--paper); border: 3px solid var(--ink); box-shadow: 8px 8px 0 rgba(26,23,19,0.35);
  max-width: 560px; margin: 0 16px; padding: 22px 26px; text-align: center;
}
.help-card h3 { font-family: 'Arial Black', sans-serif; letter-spacing: 3px; font-size: 16px; margin-bottom: 10px; }
.help-objective { font-style: italic; font-size: 15px; margin-bottom: 8px; }
.help-hint { font-size: 14px; color: var(--red); font-weight: bold; margin-bottom: 14px; }
.help-cols { display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; line-height: 1.6; color: #57503f; margin-bottom: 16px; }
.help-cols b { color: var(--ink); }

/* banner */
.banner { background: var(--paper); pointer-events: none; flex-direction: column; }
.banner.slim { background: transparent; }
.banner.slim::before, .banner.slim::after { display: none; }
.banner.slim #bannerInner {
  background: var(--paper); border: 3px solid var(--ink);
  box-shadow: 8px 8px 0 rgba(26,23,19,0.35); padding: 16px 34px; max-width: 560px;
}
.banner.slim #bannerInner h2 { font-size: 32px; margin: 6px 0 8px; }
.banner.slim #bannerInner p { font-size: 14px; }
.banner.slim .lvltxt { font-size: 13px; }
.banner.sticky { pointer-events: auto; }
#bannerInner button { pointer-events: auto; margin-top: 14px; }
.banner::before, .banner::after {
  content: ''; position: absolute; left: 0; right: 0; height: 12px; background: var(--ink);
}
.banner::before { top: 26%; }
.banner::after { bottom: 26%; }
.banner.hidden { display: none; }
#bannerInner { text-align: center; }
#bannerInner h2 {
  font-family: 'Arial Black', sans-serif;
  font-size: 54px; letter-spacing: 4px; color: var(--ink);
  margin: 10px 0 12px; text-shadow: 4px 4px 0 var(--red);
}
#bannerInner p { color: #57503f; font-size: 17px; line-height: 1.7; white-space: pre-line; font-style: italic; }
.lvltxt { font-family: 'Arial Black', sans-serif; font-size: 16px; letter-spacing: 8px; color: var(--red); margin-bottom: 4px; }
@keyframes bannerIn {
  from { transform: scale(0.92) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}
#bannerInner h2 { animation: bannerIn .35s cubic-bezier(.2,.9,.3,1.15); }

/* blink fade: ink wipe */
#fade { position: absolute; inset: 0; background: var(--ink); opacity: 0; pointer-events: none; z-index: 8; transition: opacity .13s ease-in; }

/* ── responsive scaling & touch ─────────────────────────────── */
#app { width: 960px; height: 600px; flex-shrink: 0; transform-origin: center center; }
html, body { touch-action: none; overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
input#joinCode { -webkit-user-select: text; user-select: text; }

#touch { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
#touch.hidden { display: none; }
#stickZone { position: absolute; left: 0; bottom: 0; width: 45%; height: 60%; pointer-events: auto; touch-action: none; }
#stick { position: absolute; width: 110px; height: 110px; margin: -55px 0 0 -55px; border-radius: 50%; background: rgba(26,23,19,0.08); border: 3px solid var(--ink); display: none; }
#stickKnob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: var(--ink); border: 3px solid var(--red); }
#touchButtons { position: absolute; right: 18px; bottom: 24px; display: flex; flex-direction: column; gap: 14px; align-items: center; pointer-events: auto; }
.tbtn {
  width: 92px; height: 92px; border-radius: 50%; font-size: 15px; letter-spacing: 1px;
  background: var(--paper); border: 3px solid var(--ink); color: var(--ink); padding: 0;
  box-shadow: 5px 5px 0 rgba(26,23,19,0.4);
}
.tbtn.big { width: 110px; height: 110px; background: var(--red); color: var(--paper); border-color: var(--ink); }
.tbtn.small { width: 72px; height: 72px; font-size: 12px; }
.tbtn.small.hidden { display: none; }
.tbtn:active { transform: translate(3px,3px); box-shadow: 1px 1px 0 rgba(26,23,19,0.4); }

#rotate { display: none; position: fixed; inset: 0; z-index: 50; background: var(--paper); color: var(--ink); align-items: center; justify-content: center; text-align: center; font-size: 19px; line-height: 1.8; font-style: italic; }
@media (orientation: portrait) and (pointer: coarse) { #rotate { display: flex; } }

@media (pointer: coarse) {
  .title { font-size: 64px; letter-spacing: 5px; }
  .code { font-size: 58px; letter-spacing: 10px; }
  button { padding: 12px 28px; }
  #controlsCard div:not(#touchHint) { display: none; }
}

/* menu lets the printed canvas show through */
#menu { background: transparent; }
#roomScreen { background: var(--paper); }

/* ── soft theme: friendlier, less brutalist UI (canvas art unchanged) ── */
:root { --red: #b3361f; --shadow: 0 6px 18px rgba(26,23,19,0.14); --radius: 12px; --muted: #4a4336; }
body, button, input, .label, .code, .title, #bannerInner h2, .lvltxt, .help-card h3,
#howTo summary, .controls-card b, #playerTag, #levelTag, #blinkLabel, #phaseChip, #interactPrompt {
  font-family: system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}
.title { font-weight: 800; letter-spacing: 2px; text-shadow: 0 4px 0 rgba(179,54,31,0.35); }
.code { letter-spacing: 8px; text-shadow: none; }
.how, .roomhelp, .controls-card, .help-cols, #bannerInner p, #controlsHint, .label { color: var(--muted); }
.label, .lvltxt, #howTo summary, .help-card h3 { letter-spacing: 1.5px; }
button {
  border: 2px solid var(--ink); border-radius: var(--radius); letter-spacing: 1px; font-weight: 700;
  box-shadow: var(--shadow); transition: background-color .15s, color .15s, transform .15s, box-shadow .15s;
}
button:hover { background: var(--ink); color: var(--paper); box-shadow: 0 8px 22px rgba(26,23,19,0.22); transform: translateY(-1px); }
button:active { transform: translateY(1px); box-shadow: var(--shadow); }
#howTo, .help-card, .banner.slim #bannerInner, #objective, #joinCode {
  border: 2px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow);
}
#joinCode { letter-spacing: 6px; }
#levelTag, #blinkChip, #phaseChip, #interactPrompt, #toast, #btnLeave2, #btnHelp, #btnMute, #btnPause, #btnSwitch {
  border-width: 2px; border-radius: 8px; box-shadow: var(--shadow);
}
#blinkLabel, #phaseChip { letter-spacing: 1px; }
#bannerInner h2 { letter-spacing: 1px; text-shadow: none; }
.banner::before, .banner::after { height: 4px; border-radius: 2px; }
.tbtn { border-width: 2px; box-shadow: var(--shadow); }
.tbtn:active { transform: scale(0.95); box-shadow: var(--shadow); }
canvas#game { border-radius: 6px; box-shadow: 0 12px 40px rgba(26,23,19,0.2); }

/* ── intro screen: hero left, play card right ── */
#menu { align-items: stretch; }
.menu-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 48px; align-items: center; width: 100%; padding: 40px 64px; }
.hero { text-align: left; min-width: 0; }
.hero .title { font-size: 92px; margin: 0; letter-spacing: 0; }
.hero .tagline { margin: 6px 0 22px; font-size: 18px; }
.steps { list-style: none; display: grid; gap: 12px; margin-bottom: 18px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; line-height: 1.45; color: var(--muted); }
.steps li b { color: var(--ink); }
.steps em { color: var(--red); font-style: normal; font-weight: 700; }
.steps span {
  flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--paper);
  display: grid; place-items: center; font-weight: 800; font-size: 13px;
}
.hero #howTo { margin: 0; max-width: none; padding: 10px 14px; }
.hero #howTo[open] { max-height: 250px; overflow: auto; }
.hero .controls-card { margin-top: 8px; padding-top: 10px; border-top: 1px solid rgba(26,23,19,0.2); line-height: 1.7; font-size: 12.5px; text-align: left; }
.play-card {
  background: var(--paper); border: 2px solid var(--ink); border-radius: 18px; box-shadow: 0 14px 40px rgba(26,23,19,0.16);
  padding: 26px; display: flex; flex-direction: column; gap: 14px; margin-top: 90px;
}
.play-card button { width: 100%; padding: 14px; font-size: 17px; }
#btnCreate { background: var(--ink); color: var(--paper); }
#btnCreate:hover { background: var(--red); border-color: var(--red); }
.play-card .join-row { gap: 10px; }
.play-card #joinCode { flex: 1; width: auto; min-width: 0; font-size: 22px; }
.play-card #btnJoin { width: auto; padding: 12px 22px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: rgba(26,23,19,0.25); }
.play-card .error { margin: 0; min-height: 18px; font-size: 13px; }
button.ghost { background: transparent; box-shadow: none; border-style: dashed; display: flex; flex-direction: column; gap: 2px; font-size: 15px; }
button.ghost small { font-weight: 400; font-size: 12px; letter-spacing: 0; opacity: 0.8; }
#btnVoice { position: absolute; top: 12px; left: 172px; pointer-events: auto; width: auto; height: 32px; padding: 0 10px; font-size: 12px; }
#btnVoice.on { background: #2f8f55; color: #fff; border-color: #2f8f55; }
@media (pointer: coarse) { .hero .title { font-size: 80px; } .menu-grid { padding: 24px 32px; gap: 28px; } }
