:root {
  --ink: #2b1d12;
  --sky: #4fb3ff;
  --gold: #ffd23f;
  --red: #e63946;
  --green: #2fb344;
  --paper: #fff8e6;
  --font: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --display: "Arial Black", Impact, "Trebuchet MS", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: #14102a; color: var(--paper); font: 16px/1.4 var(--font); }
h1, h2, h3 { font-family: var(--display); }
a { color: var(--gold); }

.btn {
  font: 700 15px var(--font); cursor: pointer; color: var(--ink); background: var(--gold);
  border: 3px solid var(--ink); border-radius: 10px; padding: 8px 16px; box-shadow: 0 4px 0 var(--ink);
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.secondary { background: #fff; }
.btn.danger { background: #ff8a8a; }
.btn.small { padding: 4px 10px; font-size: 13px; box-shadow: 0 3px 0 var(--ink); }

/* ---------- game page ---------- */
.rules {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; padding: 10px 12px;
  background: #1d1740; border-bottom: 3px solid var(--ink); font-size: 14px;
}
.rules span { display: inline-flex; align-items: center; gap: 6px; }
kbd {
  font: 700 13px var(--font); color: var(--ink); background: #fff; border: 2px solid var(--ink);
  border-radius: 6px; padding: 1px 7px; box-shadow: 0 2px 0 var(--ink); min-width: 26px; text-align: center;
}
body.game { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; background: #0b0820; }
/* The 16:9 stage is letterboxed inside whatever space is left under the rules bar. */
.stage-wrap { flex: 1; min-height: 0; container-type: size; display: grid; place-items: center; }
.stage { position: relative; width: min(100cqw, calc(100cqh * 16 / 9)); aspect-ratio: 16 / 9; }
.quit { position: absolute; bottom: 2.2%; left: 1.6%; z-index: 3; }
.dlcv { position: absolute; bottom: 2.2%; right: 1.6%; z-index: 3; display: inline-flex; align-items: center; gap: 6px; }
.dlcv[hidden] { display: none; }
#confirm { z-index: 5; }
.pdf-icon { display: block; margin: 0 auto .4em; }
.card .row .btn kbd { margin-left: 6px; font-size: 12px; min-width: 20px; padding: 0 5px; box-shadow: 0 1px 0 var(--ink); }
.card .row { display: flex; gap: 14px; justify-content: center; margin-top: 1em; }
.card .row .btn { min-width: 96px; font-size: 18px; }
@media (pointer: coarse) { .quit, .dlcv { bottom: 30%; } }   /* clear of the on-screen arrows */
.stage canvas { width: 100%; height: 100%; display: block; background: #000; image-rendering: auto; }
.overlay {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(10, 8, 30, .62); padding: 4%;
}
.overlay.show { display: flex; }
.card {
  background: var(--paper); color: var(--ink); border: 5px solid var(--ink); border-radius: 18px;
  box-shadow: 0 8px 0 rgba(0,0,0,.45); padding: 3% 4%; max-width: 78%; max-height: 90%; overflow: auto; text-align: left;
}
.card h2 { margin: 0 0 .5em; font-size: clamp(20px, 3.2vw, 36px); }
.card h2 .dates { display: block; margin-top: .25em; font: 700 clamp(13px, 1.7vw, 19px) var(--font); opacity: .6; }
.card p { margin: 0 0 1em; font-size: clamp(14px, 1.9vw, 22px); white-space: pre-wrap; overflow-wrap: anywhere; }
.card .hint { margin: 0; font-size: 14px; opacity: .7; }
#banner { pointer-events: none; background: rgba(10, 8, 30, .5); }
#banner .card { text-align: center; }
#banner small { display: block; font: 700 clamp(12px, 1.6vw, 18px) var(--font); opacity: .7; text-transform: uppercase; letter-spacing: .08em; }
.touch { display: none; position: absolute; bottom: 2%; left: 2%; right: 2%; justify-content: space-between; pointer-events: none; }
.touch div { display: flex; gap: 10px; }
.touch button {
  pointer-events: auto; width: 62px; height: 62px; font-size: 24px; border-radius: 50%; touch-action: none;
  border: 3px solid var(--ink); background: rgba(255, 255, 255, .85); color: var(--ink); font-weight: 700;
}
@media (pointer: coarse) { .touch { display: flex; } }
.error { display: grid; place-items: center; min-height: 70vh; text-align: center; padding: 20px; }

/* ---------- menu ---------- */
.menu-wrap { position: relative; min-height: 100vh; min-height: 100dvh; overflow: hidden; display: grid; place-items: center; }
.menu-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.menu { position: relative; text-align: center; padding: 20px; }
.menu h1 {
  padding-bottom: 8px;
  margin: 0 0 6px; font-size: clamp(40px, 9vw, 96px); line-height: 1; color: var(--gold);
  -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink); letter-spacing: 1px;
}
.menu .sub { margin: 0 0 28px; font: 700 clamp(14px, 2vw, 20px) var(--font); color: #fff; text-shadow: 0 2px 0 var(--ink); }
.menu ul { list-style: none; margin: 0 auto; padding: 0; width: min(380px, 90vw); display: grid; gap: 12px; max-height: 50vh; overflow: auto; padding: 6px; }
.menu li button {
  width: 100%; text-align: center; font: 900 22px var(--display); color: var(--ink); background: #fff;
  border: 4px solid var(--ink); border-radius: 14px; padding: 12px 16px; cursor: pointer; box-shadow: 0 5px 0 var(--ink);
}
.menu li.sel button { background: var(--gold); }
.menu li.sel button::before { content: "▶ "; }
.menu .empty { background: var(--paper); color: var(--ink); border: 4px solid var(--ink); border-radius: 14px; padding: 14px; font-weight: 700; }
.menu .tip { margin-top: 22px; color: #fff; text-shadow: 0 2px 0 var(--ink); font-size: 14px; }

/* ---------- admin ---------- */
.admin { max-width: 880px; margin: 0 auto; padding: 24px 16px 60px; }
.admin header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.admin h1 { margin: 0; font-size: 26px; color: var(--gold); }
.panel { background: #231c4d; border: 3px solid var(--ink); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
.panel h2, .panel h3 { margin: 0 0 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
input[type=text], input[type=password], textarea {
  font: 16px var(--font); padding: 9px 11px; border: 3px solid var(--ink); border-radius: 9px; background: #fff; color: var(--ink); width: 100%;
}
textarea { min-height: 140px; resize: vertical; }
label { display: block; font-weight: 700; margin: 10px 0 4px; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list li { display: flex; align-items: center; gap: 8px; background: #2d2560; border-radius: 10px; padding: 8px 10px; }
.list li .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list a { font-weight: 700; }
.muted { opacity: .65; font-size: 14px; }
.msg { color: #ff9a9a; font-weight: 700; min-height: 1.4em; margin: 8px 0 0; }
.level-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.level-head h3 { margin: 0; font-size: 18px; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal form { background: var(--paper); color: var(--ink); border: 4px solid var(--ink); border-radius: 16px; padding: 20px; width: min(560px, 100%); max-height: 95vh; overflow: auto; }
.modal h2 { margin: 0 0 6px; }
.modal .row { justify-content: flex-end; margin-top: 16px; }

.check { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; font-weight: 700; }
.check input { width: 20px; height: 20px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type=month], input[type=date] { font: 16px var(--font); padding: 9px 11px; border: 3px solid var(--ink); border-radius: 9px; background: #fff; color: var(--ink); width: 100%; }
input:disabled { opacity: .45; }
.list .dates { opacity: .6; font-size: 13px; white-space: nowrap; }

/* ---------- how to play ---------- */
.howto { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 10px 0; }
.howto[hidden] { display: none; }
.howto .stage { width: min(100vw, calc((100dvh - 90px) * 16 / 9)); }
.menu-wrap[hidden] { display: none; }

/* ---------- phones ---------- */
.rotate {
  display: none; position: fixed; inset: 0; z-index: 50; background: #14102a; color: #fff; text-align: center;
  flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px;
}
.rotate p { margin: 0; font: 700 20px var(--font); }
.rotate .phone { width: 54px; height: 92px; border: 5px solid #fff; border-radius: 12px; position: relative; animation: turn 2.4s ease-in-out infinite; }
.rotate .phone::after { content: ""; position: absolute; left: 50%; bottom: 6px; width: 14px; height: 4px; margin-left: -7px; background: #fff; border-radius: 2px; }
@keyframes turn { 0%, 25% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (orientation: portrait) and (pointer: coarse) { .rotate { display: flex; } }
@media (max-height: 520px) {
  .rules { padding: 4px 8px; gap: 2px 14px; font-size: 12px; }
  kbd { font-size: 11px; padding: 0 5px; min-width: 20px; box-shadow: 0 1px 0 var(--ink); }
  .quit, .dlcv { padding: 3px 9px; font-size: 12px; }
}
@media (max-width: 520px) {
  .menu h1 { -webkit-text-stroke-width: 2px; text-shadow: 0 4px 0 var(--ink); }
  .menu li button { font-size: 19px; padding: 10px 14px; }
}
.error[hidden] { display: none; }
