@font-face { font-family: "Fraunces"; src: url("fonts/Fraunces.ttf") format("truetype"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Inter"; src: url("fonts/Inter-SemiBold.ttf") format("truetype"); font-weight: 400 700; font-display: swap; }

:root {
  --night: #0a1222; --deep: #111d36; --slate: #1b2b4b; --steel: #34507a; --mist: #7fa7c9;
  --ice: #a9dcef; --frost: #e8f5fb; --lamp: #ffd27a; --amber: #ffb347;
  --ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --title: "Fraunces", Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--frost); font-family: var(--ui); font-weight: 600; }
body { overflow: hidden; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
#app { position: fixed; inset: 0; }
[hidden] { display: none !important; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, canvas:focus-visible { outline: 3px solid var(--lamp); outline-offset: 2px; }
canvas:focus { outline: none; }

/* ---- home ---- */
#home { overflow-y: auto; background: linear-gradient(#060c18, #122041); }
.home-head { position: relative; text-align: center; padding: 14px 52px 4px; }
.home-head h1 { font-family: var(--title); font-weight: 600; font-size: clamp(26px, 4.4vw, 40px); margin: 0; letter-spacing: 0.01em; color: var(--frost); text-shadow: 0 0 18px rgba(169,220,239,0.35); }
.tagline { margin: 2px 0 0; color: var(--mist); font-size: 14px; }
.home-head .mute { position: absolute; right: 10px; top: 12px; }
.home-body { flex: 1; display: flex; gap: 12px; padding: 8px 14px 14px; min-height: 0; }
.tower-wrap { flex: 0 0 34%; display: flex; flex-direction: column; min-height: 0; }
#tower { flex: 1; width: 100%; min-height: 160px; border-radius: 14px; }
.lamp-count { text-align: center; color: var(--lamp); font-size: 13px; margin: 6px 0 0; }
.doors-wrap { flex: 1; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
#doors { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.door { position: relative; aspect-ratio: 1 / 1.05; border-radius: 10px; border: 2px solid rgba(169,220,239,0.35);
  background: linear-gradient(160deg, #22406a, #172c4c); display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0; transition: transform 0.08s ease, box-shadow 0.15s ease; min-height: 44px; }
.door:active { transform: scale(0.95); }
.door .num { font-family: var(--title); font-size: clamp(20px, 3.2vw, 30px); font-weight: 600; line-height: 1; }
.door .sub { font-size: 10px; color: var(--mist); margin-top: 3px; min-height: 12px; letter-spacing: 0.02em; }
.door.open { box-shadow: 0 0 0 1px rgba(169,220,239,0.2), 0 0 14px rgba(169,220,239,0.18); }
.door.open:hover { box-shadow: 0 0 0 2px var(--ice), 0 0 18px rgba(169,220,239,0.35); }
.door.date, .door.full { background: linear-gradient(160deg, #18263f, #111c31); border-color: rgba(127,167,201,0.18); color: #5f7896; }
.door.date .num, .door.full .num { opacity: 0.7; }
.door.solved { background: radial-gradient(circle at 50% 40%, #ffe7ad, #f2a948 70%, #c97a2b); border-color: #ffe7ad; color: #3a2410; box-shadow: 0 0 18px rgba(255,190,90,0.55); }
.door.solved .sub { color: #5a3a12; }
.note { color: var(--mist); font-size: 13px; text-align: center; margin: 10px 0 0; }
.door-top { text-align: center; margin-bottom: 6px; }
.door-top .note { margin: 0; }
.door-top .link-btn { padding: 4px 10px 8px; min-height: 44px; }
.link-btn { background: none; border: none; color: var(--ice); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; padding: 10px; margin-top: 2px; }

@media (max-aspect-ratio: 1/1) {
  .home-body { flex-direction: column; }
  .tower-wrap { flex: 0 0 auto; height: 30vh; min-height: 170px; }
  #doors { grid-template-columns: repeat(4, 1fr); gap: 7px; }
  .door { aspect-ratio: 1.25 / 1; }
}

/* ---- room ---- */
.bar { display: flex; align-items: center; gap: 4px; padding: 6px 8px; height: 52px; flex: 0 0 52px; background: rgba(10,18,34,0.9); border-bottom: 1px solid rgba(169,220,239,0.12); }
.room-title { flex: 1; min-width: 0; font-family: var(--title); font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
.icon-btn { width: 42px; height: 42px; border-radius: 10px; border: none; background: transparent; display: grid; place-items: center; color: var(--frost); }
.icon-btn:hover { background: rgba(169,220,239,0.1); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }
.icon-btn svg { width: 24px; height: 24px; }
.mute .cross { display: none; }
.mute.off .cross { display: inline; }
.mute.off .wave { display: none; }
#stage-wrap { position: relative; flex: 1; min-height: 0; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.goal { flex: 0 0 auto; margin: 0; padding: 8px 14px 12px; text-align: center; color: var(--ice); font-size: 15px; min-height: 40px; }

.hint-box { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); width: min(520px, calc(100% - 24px));
  background: rgba(17,29,54,0.96); border: 1px solid rgba(255,210,122,0.5); border-radius: 12px; padding: 10px 14px; font-size: 15px; box-shadow: 0 8px 30px rgba(0,0,0,0.5); }
.hint-box p { margin: 4px 0 8px; line-height: 1.35; }
.hint-box b { color: var(--lamp); }
.hint-row { display: flex; gap: 8px; justify-content: flex-end; }

.card { background: rgba(17,29,54,0.97); border: 1px solid rgba(255,210,122,0.55); border-radius: 16px; padding: 20px 22px; text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6), 0 0 40px rgba(255,190,90,0.15); width: min(420px, calc(100% - 28px)); }
#solved { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); animation: pop 0.35s cubic-bezier(.2,1.4,.4,1); }
.card h2 { font-family: var(--title); font-weight: 600; margin: 0 0 8px; color: var(--lamp); font-size: 26px; }
.card p { margin: 0 0 16px; color: var(--frost); line-height: 1.4; font-size: 15px; }
.card-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn { min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid rgba(169,220,239,0.4); background: var(--slate); font-size: 15px; }
.btn:hover { border-color: var(--ice); }
.btn.primary { background: linear-gradient(#ffd98a, #f0a845); color: #2a1a08; border-color: #ffe3a6; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
@media (pointer: coarse) { .btn.small { min-height: 44px; } }
.overlay { position: absolute; inset: 0; background: rgba(4,8,16,0.7); display: grid; place-items: center; z-index: 10; }
@keyframes pop { from { transform: translateX(-50%) translateY(20px) scale(0.9); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
@media (max-width: 420px) {
  #mute { display: none; }
  .room-title { font-size: 16px; white-space: normal; line-height: 1.1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; padding: 0 2px; }
  .bar { gap: 0; }
}
/* solved card beside the stage (wide screens) or below it (tall screens), so the lit room stays visible */
#solved.side { bottom: auto; top: 50%; transform: translateY(-50%); animation: popSide 0.35s cubic-bezier(.2,1.4,.4,1); padding: 18px 16px; }
#solved.side .card-row { flex-direction: column; }
#solved.side .btn { width: 100%; font-size: 14px; padding: 0 10px; }
#solved.side h2 { font-size: 23px; }
#solved.below { bottom: auto; }
.goal.done { display: none; }
@keyframes popSide { from { transform: translateY(-50%) translateX(20px) scale(0.9); opacity: 0; } to { transform: translateY(-50%) scale(1); opacity: 1; } }
@media (max-width: 420px) { .card { padding: 14px 14px; } .card h2 { font-size: 22px; margin-bottom: 4px; } .card p { font-size: 14px; margin-bottom: 10px; } }
.hint-box.below { bottom: auto; }
.hint-box.side { bottom: auto; top: 50%; transform: translateY(-50%); }
.goal.hinting { display: none; }
