:root {
  color-scheme: dark;
  --ink: #121222;
  --panel: #1d1d32;
  --line: #35344f;
  --text: #f7f4ff;
  --sub: #bbb8d0;
  --violet: #a894ff;
  font-family: Inter, "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 48% 0%, #24203e 0%, transparent 57%), var(--ink);
  color: var(--text);
}
main { width: min(1660px, calc(100% - 32px)); margin: 0 auto; padding: 32px 0 24px; }
.masthead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; }
.identity { display: flex; gap: 15px; align-items: center; }
.brand-icon { display: grid; grid-template-columns: repeat(2, 9px); grid-template-rows: repeat(2, 9px); justify-content: center; align-content: center; gap: 3px; width: 49px; height: 49px; color: #211837; background: #b39aff; border-radius: 13px; box-shadow: inset 0 -4px #9275e4, 0 6px 22px #a88bff38; }
.brand-icon i { background: currentColor; border-radius: 2px; }
.brand-icon i:first-child { grid-column: 2; }
h1,h2,h3,p { margin: 0; }
h1 { font-weight: 850; font-size: clamp(1.65rem, 4vw, 2.25rem); letter-spacing: -.06em; line-height: 1.16; }
.identity p { color: var(--sub); margin-top: 5px; font-size: .94rem; }
.connection { display: flex; align-items: center; flex-shrink: 0; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--sub); background: #222038; font-size: .88rem; }
.connection i { width: 7px; height: 7px; border-radius: 50%; background: #fbd182; }
.connection.online i { background: #a7e984; box-shadow: 0 0 10px #a7e98467; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) clamp(230px, 20vw, 280px); gap: 14px; align-items: start; }
.board,.party { border: 1px solid var(--line); background: var(--panel); border-radius: 16px; }
.board { overflow: hidden; box-shadow: 0 18px 40px #0909145c; }
.board-bar,.board-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 8px 16px; }
.board-bar { background: #24223b; }
.stage-head,.exit-count { display: flex; align-items: center; gap: 10px; }
.stage-head h2 { font-size: 1.02rem; line-height: 1.3; }
#stage-number { display: grid; place-items: center; border-radius: 6px; background: #3b315c; color: #d9cbff; min-width: 34px; height: 28px; font: 700 .89rem ui-monospace, monospace; }
.exit-count { font-size: .88rem; color: var(--sub); white-space: nowrap; }
.door-icon { width: 11px; height: 14px; border: 2px solid #a99ad8; border-radius: 4px 4px 1px 1px; position: relative; }
.door-icon::after { content: ""; position: absolute; width: 2px; height: 2px; background: #a99ad8; right: 1px; top: 5px; }
.view { position: relative; background: #17172a; }
canvas { display: block; width: 100%; height: auto; aspect-ratio: 7 / 3; }
.board-footer { justify-content: flex-end; border-top: 1px solid #302d4d; }
button,input,select { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: default; opacity: .45; }
button:not(:disabled):hover { filter: brightness(1.14); }
button:focus-visible,input:focus-visible,select:focus-visible { outline: 2px solid #e4d4ff; outline-offset: 3px; }
.icon-button { margin-left: auto; display: grid; place-items: center; flex: 0 0 32px; height: 32px; padding: 0; color: #ddd2f8; background: #302a47; border: 1px solid #4a4065; border-radius: 7px; font-size: 1.2rem; }
.party { padding: 19px; min-height: 327px; }
.party-head { display: flex; align-items: center; gap: 11px; padding-bottom: 20px; }
.party-head h2 { font-size: 1.12rem; }
.party-head p,.party-note { color: var(--sub); font-size: .88rem; line-height: 1.42; margin-top: 4px; }
.party-icon { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: #392f58; border-radius: 9px; gap: 3px; color: #ccbaff; }
.party-icon i { width: 9px; height: 9px; border: 2px solid currentColor; border-radius: 50%; position: relative; margin-top: -6px; }
.party-icon i::after { content: ""; position: absolute; top: 8px; left: -3px; width: 11px; height: 5px; border: 2px solid currentColor; border-bottom: 0; border-radius: 6px 6px 0 0; }
.party-icon i:last-child { transform: scale(.77); opacity: .67; }
.button { border: 1px solid transparent; border-radius: 8px; min-height: 42px; padding: 7px 11px; font-size: .93rem; font-weight: 700; white-space: nowrap; }
.primary { width: 100%; color: #1f1636; background: var(--violet); border-color: #c1b0ff; box-shadow: inset 0 -3px #8870d8; min-height: 44px; }
.primary span { margin-right: 6px; }
.secondary { background: #34304e; border-color: #4a4167; color: #eee7ff; }
.divider { display: flex; align-items: center; gap: 9px; margin: 15px 0; font-size: .81rem; color: var(--sub); }
.divider::before,.divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }
label,.code-heading { display: block; margin-bottom: 8px; color: #ded8f0; font-size: .88rem; font-weight: 650; }
.join-row,.room-code { display: flex; gap: 7px; min-width: 0; }
input { width: 100%; min-width: 0; border: 1px solid #47425e; border-radius: 7px; padding: 0 10px; background: #151526; color: #f5f1ff; text-transform: uppercase; font: 700 .94rem ui-monospace, monospace; letter-spacing: .08em; }
input::placeholder { color: #a39ab7; }
#start-section { width: 100%; margin-bottom: 10px; min-height: 42px; border: 1px solid #47425e; border-radius: 7px; padding: 6px 10px; background: #151526; color: #f5f1ff; }
.party-note { margin-top: 12px; }
.code-heading { display: flex; justify-content: space-between; }
.room-code { align-items: center; justify-content: space-between; }
.room-code strong { font: 800 1.32rem ui-monospace, monospace; letter-spacing: .13em; color: #d8caff; }
.room-code .button { min-height: 34px; font-size: .83rem; }
.players { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 138px), 1fr)); gap: 6px; margin: 14px 0; min-height: 32px; }
.player { display: flex; align-items: center; gap: 6px; background: #29263e; border-radius: 6px; min-height: 34px; padding: 4px 7px; font-size: .82rem; white-space: nowrap; }
.player i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.player.disconnected :is(i,span,small) { opacity: .55; }
.player small,.player .kick { flex-shrink: 0; margin-left: auto; font-size: .74rem; }
.player small { color: #c8bde8; }
.player .kick { min-height: 26px; padding: 2px 7px; border: 1px solid #6a485e; border-radius: 5px; background: #3a293d; color: #ffc1d3; }
#look-picker { padding: 0; margin: 0 0 15px; border: 0; min-width: 0; }
#look-picker legend { margin-bottom: 7px; font-size: .85rem; color: #ded8f0; font-weight: 650; }
#looks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
#looks button { display: flex; gap: 6px; align-items: center; justify-content: center; padding: 3px; min-height: 35px; border: 1px solid #494360; border-radius: 7px; background: #29263e; font-size: .84rem; }
#looks button[aria-pressed="true"] { border-color: #bbacff; background: #453962; }
#looks i { width: 27px; height: 29.25px; flex: 0 0 27px; background-size: 800% 400%; background-repeat: no-repeat; }
.room-links { display: flex; justify-content: space-between; margin-top: 9px; }
.room-links button { background: none; border: none; padding: 4px 0; font-size: .85rem; color: var(--sub); }
.notice { color: #ffd599; font-size: .88rem; line-height: 1.55; margin-top: 12px; overflow-wrap: anywhere; }
.result { position: absolute; inset: 0; display: grid; place-items: center; background: #110e24a6; text-align: center; pointer-events: none; }
.result-box { background: #27213f; border: 1px solid #665787; border-radius: 13px; padding: 14px 25px; box-shadow: 0 18px 55px #121022; max-width: 85%; }
.result strong,.result span { display: block; }
.result strong { font-size: clamp(1.04rem, 3vw, 1.75rem); color: #e1d4ff; }
.result span { margin-top: 6px; color: #d4cbe8; font-size: .88rem; }
.result.celebrating { background: #110e2455; }
.result.celebrating .result-box { position: relative; border-color: #e6b979; box-shadow: 0 0 36px #f7b36740; }
.result.celebrating strong { color: #ffe3a2; }
.fireworks { position: absolute; inset: 0; overflow: hidden; }
.fireworks i {
  --reach: clamp(34px, 8vw, 90px);
  position: absolute;
  left: 20%;
  top: 40%;
  width: clamp(4px, .6vw, 8px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff7d5;
  color: #ffd073;
  box-shadow:
    var(--reach) 0 currentColor, calc(-1 * var(--reach)) 0 currentColor,
    0 var(--reach) currentColor, 0 calc(-1 * var(--reach)) currentColor,
    calc(.7 * var(--reach)) calc(.7 * var(--reach)) #fbe9b1,
    calc(-.7 * var(--reach)) calc(.7 * var(--reach)) #fbe9b1,
    calc(.7 * var(--reach)) calc(-.7 * var(--reach)) #fbe9b1,
    calc(-.7 * var(--reach)) calc(-.7 * var(--reach)) #fbe9b1,
    calc(.36 * var(--reach)) calc(.28 * var(--reach)) 2px #fff6dd,
    calc(-.36 * var(--reach)) calc(-.28 * var(--reach)) 2px #fff6dd;
  animation: firework-burst 1.35s ease-out var(--delay, 0s) both;
}
.fireworks i:nth-child(2) { left: 79%; top: 32%; color: #8eeaff; --delay: .22s; --spin: 19deg; }
.fireworks i:nth-child(3) { left: 35%; top: 78%; color: #ffa5d5; --delay: .62s; --spin: 13deg; }
.fireworks i:nth-child(4) { left: 70%; top: 68%; color: #bfabff; --delay: .85s; --spin: 28deg; }
@keyframes firework-burst {
  from { opacity: 0; transform: translate(-50%, -50%) rotate(var(--spin, 0deg)) scale(.08); }
  12% { opacity: 1; }
  60% { opacity: .85; }
  to { opacity: 0; transform: translate(-50%, -12%) rotate(var(--spin, 0deg)) scale(1); }
}
@media (prefers-reduced-motion: reduce) { .fireworks { display: none; } }
.practice-guide {
  position: absolute;
  inset: clamp(8px, 2vw, 24px) 8px auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px clamp(6px, 1vw, 12px);
  pointer-events: none;
}
.practice-guide span {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  color: #ede6ff;
  background: #211a34e8;
  border: 1px solid #a995cf52;
  border-radius: 6px;
  font-size: clamp(.72rem, 1.4vw, .86rem);
  white-space: nowrap;
}
.practice-guide kbd,.tutorial-keys kbd {
  min-width: 18px;
  padding: 2px 4px;
  color: #fff0ca;
  background: #332847;
  border: 1px solid #726287;
  border-bottom-width: 2px;
  border-radius: 4px;
  font: 650 .75rem ui-monospace, monospace;
  text-align: center;
}
.tutorial-guide { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; padding: 8px 14px; background: #252137; }
.tutorial-keys { display: flex; flex-wrap: wrap; gap: 6px 12px; color: #ddd4ed; font-size: .82rem; }
.tutorial-keys span { white-space: nowrap; }
.tutorial-keys kbd { display: inline-block; }
#tutorial-tip { color: #e8deef; font-size: .86rem; line-height: 1.4; }
.touch { display: none; justify-content: space-between; gap: 8px; padding: 8px 11px 11px; }
.touch div { display: flex; gap: 5px; }
.touch button { min-width: 43px; min-height: 42px; background: #383053; border-radius: 7px; border: 1px solid #5c4c7a; padding: 4px 7px; font-size: .86rem; touch-action: none; }
.touch button[aria-pressed="true"] { background: #7564a8; }
@media (pointer: coarse) { .touch { display: flex; } }
@media (max-width: 900px) {
  main { width: calc(100% - 20px); padding-top: 24px; }
  .game-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .party { min-height: 0; padding: 14px; }
}
@media (max-width: 650px) {
  main { width: calc(100% - 12px); padding-top: 16px; }
  .masthead { margin-bottom: 12px; }
  .board-bar,.board-footer { padding-left: 9px; padding-right: 9px; min-height: 44px; }
}
