:root {
  --ink: #171711;
  --cream: #f5efdf;
  --paper: #fffdf6;
  --lime: #d7f23a;
  --yellow: #ffd83d;
  --blue: #4f7cff;
  --red: #ff685e;
  --green: #34b989;
  --line: rgba(23, 23, 17, 0.17);
  --shadow: 0 18px 60px rgba(33, 28, 15, 0.13);
  --display: "Arial Black", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --body: "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  --latin: "Arial Black", system-ui, sans-serif;
}

* { box-sizing: border-box; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--body);
  overflow-x: hidden;
}

button, input { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: 0.18;
  background-image: radial-gradient(rgba(23,23,17,.18) .45px, transparent .55px);
  background-size: 5px 5px;
}

.screen { min-height: 100dvh; }
.home-screen, .room-screen { padding: 28px clamp(22px, 5vw, 78px) 24px; }

.brand-row, .room-header, .game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--display);
  font-size: 23px;
  letter-spacing: -0.03em;
}

.brand-mark {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 28px;
  border: 3px solid var(--ink);
  border-radius: 52% 48% 46% 54%;
  background: var(--lime);
  transform: rotate(-5deg);
}

.brand-mark::after {
  content: "";
  position: absolute;
  right: -10px;
  bottom: 0;
  width: 17px;
  height: 8px;
  border: 3px solid var(--ink);
  border-left: 0;
  border-radius: 0 12px 12px 0;
}

.brand-mark i {
  position: absolute;
  top: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink);
}
.brand-mark i:first-child { left: 8px; }
.brand-mark i:last-child { right: 8px; }
.brand-mark.mini { width: 32px; height: 23px; border-width: 2px; }
.brand-mark.mini::after { border-width: 2px; width: 13px; height: 7px; right: -8px; }
.brand-mark.mini i { width: 5px; height: 5px; top: 4px; }

.connection-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  font-size: 13px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #aaa; }
.status-dot.online { background: var(--green); box-shadow: 0 0 0 4px rgba(52,185,137,.13); }
.status-dot.offline { background: var(--red); }

.hero {
  min-height: calc(100dvh - 158px);
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(340px, 0.72fr);
  align-items: center;
  gap: clamp(42px, 8vw, 130px);
  max-width: 1380px;
  margin: 0 auto;
  padding: 38px 0;
}

.eyebrow, .section-kicker {
  margin: 0 0 16px;
  font: 800 12px/1 var(--latin);
  letter-spacing: .2em;
}

.hero h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(58px, 7.5vw, 118px);
  font-weight: 400;
  line-height: .94;
  letter-spacing: -0.055em;
}
.hero h1 em { color: var(--blue); font-style: normal; position: relative; }
.hero h1 em::after {
  content: "";
  position: absolute;
  left: 2%; right: 0; bottom: -4px;
  height: 10px;
  background: var(--lime);
  z-index: -1;
  transform: rotate(-1deg);
}

.hero-description {
  max-width: 610px;
  margin: 30px 0 22px;
  font-size: clamp(17px, 1.4vw, 21px);
  line-height: 1.75;
  word-break: keep-all;
}

.hero-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.hero-tags span {
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 7px 13px;
  font: 700 11px/1 var(--latin);
  background: var(--paper);
}

.entry-card {
  position: relative;
  border: 2px solid var(--ink);
  border-radius: 24px;
  background: var(--paper);
  padding: 12px;
  box-shadow: 12px 12px 0 var(--ink), var(--shadow);
  transform: rotate(.35deg);
}
.entry-card::before {
  content: "NEW GAME";
  position: absolute;
  top: -15px;
  right: 24px;
  padding: 7px 12px;
  border: 2px solid var(--ink);
  background: var(--yellow);
  font: 900 10px/1 var(--latin);
  letter-spacing: .1em;
  transform: rotate(4deg);
}

.tab-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 4px; border-radius: 15px; background: #eae4d7; }
.tab {
  border: 0;
  border-radius: 11px;
  background: transparent;
  padding: 13px;
  cursor: pointer;
  font-weight: 700;
  opacity: .55;
}
.tab.is-active { background: var(--paper); box-shadow: 0 3px 14px rgba(0,0,0,.08); opacity: 1; }
.entry-panel { display: flex; flex-direction: column; gap: 10px; padding: 24px 13px 14px; }
.field-label { margin-top: 4px; font-weight: 700; font-size: 13px; }

.text-input {
  width: 100%;
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  background: white;
  padding: 14px 15px;
  outline: none;
  font-size: 17px;
  transition: box-shadow .2s, transform .2s;
}
.text-input:focus { box-shadow: 4px 4px 0 var(--lime); transform: translate(-2px,-2px); }
.code-input { text-transform: uppercase; letter-spacing: .24em; font: 800 22px/1 var(--latin); }

.upload-box {
  position: relative;
  min-height: 120px;
  margin: 5px 0 6px;
  border: 1.5px dashed var(--ink);
  border-radius: 13px;
  background: #f0ebdf;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px;
  cursor: pointer;
  overflow: hidden;
}
.upload-box input, .secondary-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-icon { display: grid; place-items: center; flex: 0 0 44px; height: 44px; border-radius: 50%; background: var(--lime); border: 1.5px solid var(--ink); font-size: 28px; line-height: 1; z-index: 1; }
.upload-copy { display: flex; flex-direction: column; gap: 4px; z-index: 1; }
.upload-copy strong { font-size: 15px; }
.upload-copy small { opacity: .6; }
.upload-box img { display: none; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: brightness(.55); }
.upload-box.has-preview img { display: block; }
.upload-box.has-preview .upload-copy { color: white; text-shadow: 0 1px 5px #000; }
.reuse-map-button { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 42px; border: 1px solid var(--ink); border-radius: 10px; background: white; padding: 9px 12px; cursor: pointer; font-size: 11px; }
.reuse-map-button strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--blue); }
.reuse-map-button.is-selected { background: var(--lime); box-shadow: 3px 3px 0 var(--ink); }
.visibility-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 2px 0 5px; padding: 0; border: 0; }
.visibility-picker legend { margin-bottom: 7px; font-size: 12px; font-weight: 800; }
.visibility-picker label { position: relative; cursor: pointer; }
.visibility-picker input { position: absolute; opacity: 0; }
.visibility-picker label > span { display: flex; min-height: 56px; flex-direction: column; justify-content: center; gap: 3px; border: 1.5px solid var(--line); border-radius: 10px; background: white; padding: 8px 10px; }
.visibility-picker strong { font-size: 12px; }
.visibility-picker small { font-size: 9px; opacity: .58; }
.visibility-picker input:checked + span { border-color: var(--ink); background: var(--lime); box-shadow: 3px 3px 0 var(--ink); }

.public-room-heading { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; font-size: 12px; }
.public-room-heading span { border-radius: 99px; background: #e8f0ff; padding: 4px 8px; color: var(--blue); font-size: 10px; font-weight: 800; }
.public-room-list { display: flex; min-height: 184px; max-height: 290px; flex-direction: column; gap: 8px; overflow-y: auto; padding: 2px 4px 5px 2px; }
.public-room-empty { display: grid; min-height: 180px; place-items: center; border: 1.5px dashed var(--line); border-radius: 12px; color: rgba(23,23,17,.55); text-align: center; font-size: 12px; line-height: 1.6; }
.public-room-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 11px; background: white; padding: 11px; }
.public-room-item > div { min-width: 0; }
.public-room-item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.public-room-item p { display: flex; gap: 7px; margin: 5px 0 0; color: rgba(23,23,17,.58); font-size: 9px; }
.public-room-item button { border: 1px solid var(--ink); border-radius: 8px; background: var(--blue); color: white; padding: 9px 10px; cursor: pointer; font-size: 10px; font-weight: 800; }

.primary-button, .secondary-button, .tool-button {
  border: 1.5px solid var(--ink);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, filter .15s;
}
.primary-button {
  min-height: 55px;
  border-radius: 12px;
  background: var(--lime);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  font-weight: 800;
  font-size: 16px;
  box-shadow: 4px 4px 0 var(--ink);
}
.primary-button.blue { background: var(--blue); color: white; }
.primary-button b { font: 800 22px/1 var(--latin); }
.primary-button:hover:not(:disabled), .tool-button:hover { transform: translate(-2px,-2px); box-shadow: 6px 6px 0 var(--ink); }
.primary-button:active:not(:disabled), .tool-button:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }
.primary-button:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.helper, .waiting-text, .key-hint { margin: 6px 0 0; text-align: center; opacity: .6; font-size: 12px; }

.home-footer { display: flex; align-items: center; justify-content: center; gap: 18px; font-size: 13px; }
.home-footer i { width: 36px; height: 1px; background: var(--ink); opacity: .25; }

/* Lobby */
.room-screen { background: #e8f0ff; }
.room-header { max-width: 1440px; margin: 0 auto 26px; }
.brand.compact { font-size: 20px; }
.room-code-box { display: flex; align-items: center; gap: 12px; padding: 7px 8px 7px 14px; border: 1.5px solid var(--ink); background: var(--paper); border-radius: 12px; }
.room-code-box > span { font: 800 9px/1 var(--latin); letter-spacing: .17em; opacity: .55; }
.room-code-box strong { font: 900 20px/1 var(--latin); letter-spacing: .16em; }
.room-code-box button { border: 0; border-radius: 8px; background: var(--ink); color: white; padding: 9px 12px; cursor: pointer; font-size: 12px; }

.lobby-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, .55fr); gap: 24px; max-width: 1440px; margin: 0 auto; }
.map-card, .players-card { border: 1.5px solid var(--ink); background: var(--paper); border-radius: 20px; padding: clamp(18px, 2vw, 28px); box-shadow: 8px 8px 0 rgba(23,23,17,.13); }
.map-heading, .players-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.map-heading h2, .players-heading h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(22px, 2.3vw, 34px); letter-spacing: -.03em; }
.section-kicker { margin-bottom: 7px; color: var(--blue); font-size: 9px; }
.map-badge { background: var(--lime); border: 1px solid var(--ink); border-radius: 999px; padding: 7px 11px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.map-preview { position: relative; aspect-ratio: 16/9; overflow: hidden; background: #d5d1c6; border: 1.5px solid var(--ink); border-radius: 12px; }
.map-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.empty-map { position: absolute; inset: 0; display: grid; place-items: center; background: repeating-linear-gradient(135deg,#e8e3d7,#e8e3d7 12px,#eee9de 12px,#eee9de 24px); }
.empty-map span { padding: 9px 13px; border: 1px solid var(--ink); background: var(--paper); border-radius: 8px; }
.scan-line { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(transparent 49%, rgba(215,242,58,.4) 50%, transparent 51%); background-size: 100% 16px; opacity: .25; }
.secondary-button { display: inline-block; position: relative; margin-top: 13px; border-radius: 9px; background: white; padding: 10px 13px; font-size: 12px; font-weight: 700; }
.game-settings { margin-top: 16px; padding: 15px; border: 1px solid rgba(23,23,17,.18); border-radius: 12px; background: #f3f0e7; }
.settings-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.settings-heading h3 { margin: 0; font-size: 17px; }
.settings-heading .section-kicker { margin-bottom: 3px; }
.settings-heading > span { padding: 5px 8px; border-radius: 99px; background: #dfdbd0; font-size: 9px; font-weight: 700; }
.settings-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.setting-card { padding: 10px; border: 1px solid rgba(23,23,17,.14); border-radius: 9px; background: white; }
.setting-card > span { display: block; margin-bottom: 8px; font-size: 11px; font-weight: 700; }
.setting-card > small { display: block; margin-top: 6px; text-align: center; font-size: 8px; opacity: .45; }
.setting-stepper { display: grid; grid-template-columns: 30px 1fr 30px; align-items: center; gap: 4px; }
.setting-stepper button { width: 30px; height: 30px; border: 1px solid var(--ink); border-radius: 7px; background: var(--cream); cursor: pointer; font: 800 16px/1 var(--latin); }
.setting-stepper button:hover:not(:disabled) { background: var(--lime); }
.setting-stepper button:disabled { opacity: .25; cursor: not-allowed; }
.setting-stepper strong { text-align: center; font: 800 15px/1 var(--latin); white-space: nowrap; }

.players-card { display: flex; flex-direction: column; }
.players-heading strong { font: 900 22px/1 var(--latin); }
.avatar-shape-picker { margin-bottom: 14px; padding: 12px; border: 1px solid rgba(23,23,17,.14); border-radius: 12px; background: #f3f0e7; }
.avatar-shape-picker > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.avatar-shape-picker > div:first-child > strong { font-size: 12px; }
.avatar-shape-picker > div:first-child > small { font-size: 9px; opacity: .58; }
.avatar-shape-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.avatar-shape-options button { display: flex; align-items: center; gap: 8px; min-width: 0; border: 1.5px solid rgba(23,23,17,.22); border-radius: 10px; background: white; padding: 6px 8px; cursor: pointer; text-align: left; }
.avatar-shape-options button:hover { border-color: var(--ink); }
.avatar-shape-options button.is-active { border-color: var(--ink); background: var(--lime); box-shadow: 3px 3px 0 var(--ink); }
.avatar-shape-options canvas { width: 32px; height: 40px; flex: 0 0 32px; }
.avatar-shape-options button > span { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.avatar-shape-options button strong { font-size: 10px; white-space: nowrap; }
.avatar-shape-options button small { font-size: 8px; opacity: .58; white-space: nowrap; }
.player-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.player-item { display: flex; align-items: center; gap: 11px; padding: 10px; border: 1px solid rgba(23,23,17,.13); border-radius: 10px; background: white; }
.player-avatar { width: 36px; height: 44px; flex: 0 0 36px; border: 1px solid rgba(23,23,17,.13); border-radius: 8px; background: var(--cream); }
.player-item strong { flex: 1; font-size: 14px; }
.player-item > span:not(.player-avatar) { font-size: 10px; font-weight: 800; color: var(--blue); }
.player-score { min-width: 48px; color: var(--ink) !important; text-align: right; font: 900 12px/1 var(--latin) !important; }
.host-tag { padding: 4px 7px; border: 1px solid var(--ink); background: var(--yellow); border-radius: 5px; color: var(--ink) !important; }
.volunteer-tag { padding: 4px 7px; border-radius: 5px; background: #e8f0ff; }
.volunteer-button { border: 1px solid var(--ink); border-radius: 6px; background: white; padding: 5px 7px; cursor: pointer; font-size: 9px; font-weight: 700; white-space: nowrap; }
.volunteer-button.is-active { background: var(--red); color: white; }
.transfer-host-button { border: 1px solid var(--ink); border-radius: 6px; background: white; padding: 5px 7px; cursor: pointer; font-size: 9px; font-weight: 700; }
.transfer-host-button:hover { background: var(--lime); }
.invite-panel { margin-top: 12px; margin-bottom: 15px; padding: 13px; border-radius: 10px; background: #edf1f8; display: flex; flex-direction: column; gap: 3px; }
.invite-panel span { font-size: 10px; opacity: .6; }
.invite-panel strong { font: 700 12px/1.4 var(--latin); overflow-wrap: anywhere; }
.room-visibility-panel { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 13px; padding: 12px 13px; border: 1px solid rgba(23,23,17,.14); border-radius: 10px; background: white; }
.room-visibility-panel > div { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.room-visibility-panel strong { font-size: 12px; }
.room-visibility-panel small { font-size: 9px; opacity: .58; line-height: 1.4; }
.switch { position: relative; flex: 0 0 42px; height: 24px; }
.switch input { position: absolute; opacity: 0; }
.switch span { position: absolute; inset: 0; border: 1px solid var(--ink); border-radius: 99px; background: #d4d0c7; cursor: pointer; transition: background .18s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .18s; }
.switch input:checked + span { background: var(--lime); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:disabled + span { cursor: not-allowed; opacity: .48; }
.waiting-text { margin-top: 15px; }

/* Game */
.game-screen { background: #191914; color: white; padding: 8px 10px 12px; }
.game-header { position: relative; width: 100%; min-height: 48px; margin: 0 0 8px; padding: 0 4px; justify-content: flex-start; }
.game-brand { display: flex; align-items: center; gap: 13px; font-family: var(--display); font-size: 22px; }
.timer-wrap { position: absolute; left: 50%; top: 50%; display: grid; grid-template-columns: auto auto; align-items: end; column-gap: 10px; min-width: 230px; transform: translate(-50%, -50%); }
.timer-wrap > span { font: 800 9px/1 var(--latin); letter-spacing: .17em; color: var(--lime); }
.timer-wrap > strong { margin-left: auto; font: 900 25px/1 var(--latin); }
.timer-track { grid-column: 1/-1; height: 5px; margin-top: 8px; background: #3d3d37; border-radius: 99px; overflow: hidden; }
.timer-track i { display: block; width: 100%; height: 100%; background: var(--lime); transform-origin: left; }
.result-header-actions { display: flex; align-items: center; gap: 7px; margin-left: auto; padding: 7px; border: 2px solid white; border-radius: 11px; background: var(--yellow); box-shadow: 5px 5px 0 var(--red); color: var(--ink); z-index: 3; }
.result-header-actions label { display: flex; align-items: center; gap: 5px; padding: 0 5px; color: var(--ink); font-size: 10px; font-weight: 900; white-space: nowrap; }
.result-header-actions input { accent-color: var(--lime); }
.result-header-actions button { min-height: 34px; border: 2px solid var(--ink); border-radius: 7px; background: var(--ink); color: white; padding: 6px 11px; cursor: pointer; font-size: 10px; font-weight: 900; white-space: nowrap; }
.result-header-actions #exportResultButton { background: var(--blue); color: white; }
.result-header-actions #skipResultButton { background: var(--red); color: var(--ink); }
.result-header-actions #skipResultButton.is-active { background: white; color: var(--ink); }
.result-header-actions button:disabled { opacity: .5; cursor: wait; }
.result-header-actions > span { min-width: 42px; color: var(--ink); font: 900 10px/1 var(--latin); white-space: nowrap; }
.round-chip { margin-left: auto; border: 1px solid #55554e; border-radius: 999px; padding: 9px 13px; font: 700 10px/1 var(--latin); letter-spacing: .1em; }
.game-header.has-result-actions .round-chip { display: none; }
.round-chip strong { color: var(--lime); }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) clamp(350px, 22vw, 420px); gap: 10px; width: 100%; margin: 0; }
.stage-column { display: flex; min-width: 0; flex-direction: column; align-items: center; }
.stage-wrap { position: relative; width: 100%; flex: 0 0 auto; aspect-ratio: 16/9; overflow: hidden; border: 2px solid #6c6c60; border-radius: 12px; background: #0b0b09; cursor: default; box-shadow: 0 18px 44px rgba(0,0,0,.3); }
.stage-wrap.is-seeking { cursor: none; border-color: var(--red); }
.stage-wrap.is-mini-game { cursor: pointer; border-color: var(--blue); }
#gameCanvas { display: block; width: 100%; height: auto; aspect-ratio: 16/9; touch-action: none; }
.stage-message { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%) rotate(-2deg); max-width: 82%; padding: 16px 22px; border: 2px solid var(--ink); background: var(--yellow); color: var(--ink); font-family: var(--display); font-size: clamp(20px,3vw,48px); text-align: center; box-shadow: 8px 8px 0 var(--ink); z-index: 3; }
.crosshair { position: absolute; width: 44px; height: 44px; transform: translate(-50%,-50%); border: 2px solid var(--red); border-radius: 50%; pointer-events: none; animation: pop .35s ease-out both; }
.crosshair::before, .crosshair::after { content: ""; position: absolute; background: var(--red); left: 50%; top: 50%; transform: translate(-50%,-50%); }
.crosshair::before { width: 58px; height: 2px; }
.crosshair::after { width: 2px; height: 58px; }

.tool-panel { align-self: stretch; min-height: 0; max-height: calc(100dvh - 65px); overflow-y: auto; border: 1px solid #4d4d47; background: #24241f; border-radius: 12px; padding: 11px; scrollbar-width: thin; }
.role-card { border-radius: 12px; padding: 14px; color: var(--ink); display: flex; flex-direction: column; gap: 2px; transform: rotate(-.6deg); }
.role-card.hider { background: var(--lime); }
.role-card.seeker { background: var(--red); }
.role-card.result { background: var(--yellow); }
.role-card > span { font: 800 8px/1 var(--latin); letter-spacing: .13em; }
.role-card > strong { font-family: var(--display); font-size: 28px; font-weight: 400; }
.role-card > small { font-size: 11px; }
.hider-guide-toggle { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 3px 10px; width: 100%; margin-top: 12px; border: 1px solid var(--lime); border-radius: 10px; background: #30302b; color: white; padding: 11px 12px; cursor: pointer; text-align: left; }
.hider-guide-toggle > span { font-size: 11px; font-weight: 800; }
.hider-guide-toggle > strong { min-width: 38px; border-radius: 999px; background: var(--lime); color: var(--ink); padding: 5px 8px; text-align: center; font: 900 10px/1 var(--latin); }
.hider-guide-toggle > small { grid-column: 1/-1; color: #aaa; font-size: 9px; }
.hider-guide-toggle.is-off { border-color: #62625b; }
.hider-guide-toggle.is-off > strong { background: var(--red); }
.tool-section { margin-top: 15px; padding: 13px; border: 1px solid #484842; border-radius: 12px; background: #1d1d19; }
.tool-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.tool-heading span { font: 800 8px/1 var(--latin); letter-spacing: .14em; color: #bcbcae; }
.tool-heading button { border: 0; background: transparent; color: #aaa99e; cursor: pointer; font-size: 10px; text-decoration: underline; }
.tool-heading-actions { display: flex; align-items: center; gap: 8px; }
.tool-heading button:disabled { cursor: not-allowed; opacity: .35; }
#avatarCanvas { display: block; width: 144px; height: 180px; margin: 0 auto 10px; border-radius: 12px; background: radial-gradient(circle, #3b3b33 1px, transparent 1.5px); background-size: 10px 10px; image-rendering: auto; touch-action: none; }
.direct-paint-hint { margin: -1px 0 10px; color: #a8a89e; text-align: center; font-size: 9px; line-height: 1.45; word-break: keep-all; }
.brush-row { display: flex; align-items: center; gap: 7px; }
#brushColor { width: 30px; height: 30px; padding: 0; border: 1px solid #777; border-radius: 6px; background: none; }
#brushColorText { font: 700 9px/1 var(--latin); color: #bbb; flex: 1; }
.brush-size { display: flex; gap: 3px; }
.brush-size button { width: 26px; height: 26px; padding: 0; border: 1px solid #555; border-radius: 5px; background: #30302b; color: white; font: 700 8px/1 var(--latin); cursor: pointer; }
.brush-size button.is-active { color: var(--ink); background: var(--lime); border-color: var(--lime); }
.color-palette { display: flex; gap: 5px; margin: 9px 0; }
.color-swatch { flex: 1; aspect-ratio: 1; border: 1px solid #666; border-radius: 5px; cursor: pointer; }
.transform-section { margin: 10px 0 4px; padding: 10px; border: 1px solid #484842; border-radius: 9px; background: #292924; }
.transform-row, .pose-control { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.transform-row > span, .pose-control > span { flex: 0 0 32px; color: #aaa99f; font-size: 9px; font-weight: 700; }
.rotation-control { display: grid; grid-template-columns: 28px 1fr 28px; align-items: center; gap: 4px; flex: 1; }
.rotation-control button, .pose-grid button { border: 1px solid #595952; border-radius: 6px; background: #363630; color: white; cursor: pointer; }
.rotation-control button { width: 28px; height: 28px; padding: 0; font-size: 15px; }
.rotation-control strong { text-align: center; font: 800 10px/1 var(--latin); }
.pose-control { align-items: flex-start; margin-top: 8px; }
.pose-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; flex: 1; }
.pose-grid button { min-height: 27px; padding: 3px; font-size: 8px; }
.pose-grid button.is-active { border-color: var(--lime); background: var(--lime); color: var(--ink); }
.rotation-control button:disabled, .pose-grid button:disabled { opacity: .32; cursor: not-allowed; }
.tool-button { width: 100%; min-height: 38px; margin-top: 7px; border-radius: 8px; background: #34342e; color: white; text-align: left; padding: 8px 10px; font-size: 10px; box-shadow: none; }
.tool-button.magic { background: var(--blue); border-color: #7292ff; }
.tool-button.is-active { background: var(--yellow); color: var(--ink); }
.shortcut-button { width: 100%; margin-top: 6px; border: 0; background: transparent; color: #aaa99f; text-align: center; cursor: pointer; font-size: 9px; }
.shortcut-button kbd { display: inline-block; min-width: 21px; margin: 0 2px; padding: 2px 5px; border: 1px solid #66665f; border-bottom-width: 2px; border-radius: 4px; background: #34342e; color: white; font: 700 9px/1 var(--latin); }
.shortcut-button.is-binding { color: var(--yellow); }
.lock-button { margin-top: 13px; min-height: 48px; }
.lock-button.is-locked { background: #55554e; color: #aaa; box-shadow: none; }
.key-hint { color: #ddd; }
.key-hint kbd { border: 1px solid #696961; border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px; background: #353530; }

.seeker-instructions { text-align: center; padding: 35px 10px 26px; }
.eye-icon { display: grid; place-items: center; width: 76px; height: 76px; margin: 0 auto 15px; border: 2px solid #73736b; border-radius: 50%; color: var(--red); font-size: 35px; }
.seeker-instructions h3 { font-family: var(--display); font-weight: 400; font-size: 24px; margin: 0 0 8px; }
.seeker-instructions p { color: #aeaea4; font-size: 12px; line-height: 1.65; margin: 0; word-break: keep-all; }
.shots-card { display: flex; align-items: center; justify-content: space-between; border: 1px solid #4d4d47; border-radius: 10px; padding: 13px; }
.shots-card span { font-size: 11px; color: #bbb; }
.shots-card strong { font: 900 28px/1 var(--latin); color: var(--red); }
.score-list { list-style: none; margin: 15px 0 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.score-list li { display: grid; grid-template-columns: 24px 1fr auto; gap: 8px; align-items: center; padding: 10px; border-radius: 8px; background: #30302b; font-size: 12px; }
.score-list li strong:last-child { font: 800 12px/1 var(--latin); color: var(--lime); }
.next-round { text-align: center; color: #aaa; font-size: 11px; }

/* Room chat */
.chat-slot { margin-top: 14px; min-height: 0; }
.game-chat-slot { margin-top: 13px; }
.chat-panel {
  display: flex;
  min-height: 280px;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(23,23,17,.22);
  border-radius: 12px;
  background: #f4f1e8;
  color: var(--ink);
}
.game-chat-slot .chat-panel {
  min-height: 300px;
  border-color: #4d4d47;
  background: #1c1c18;
  color: white;
}
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 11px; border-bottom: 1px solid rgba(23,23,17,.13); }
.game-chat-slot .chat-header { border-bottom-color: #3e3e38; }
.chat-header > div { display: flex; align-items: center; gap: 7px; }
.chat-header strong { font: 900 9px/1 var(--latin); letter-spacing: .12em; }
.chat-header small { font-size: 9px; opacity: .55; }
.chat-live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(52,185,137,.14); }
.chat-messages { height: 195px; overflow-y: auto; padding: 11px 12px; overscroll-behavior: contain; scrollbar-width: thin; }
.game-chat-slot .chat-messages { height: 215px; }
.chat-empty { margin: 24px 0; text-align: center; font-size: 10px; line-height: 1.6; opacity: .48; }
.chat-message { display: grid; grid-template-columns: 1fr auto; column-gap: 8px; margin-bottom: 9px; }
.chat-message strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; color: var(--blue); }
.game-chat-slot .chat-message strong { color: var(--lime); }
.chat-message time { font: 600 8px/1 var(--latin); opacity: .38; }
.chat-message p { grid-column: 1/-1; width: fit-content; max-width: 92%; margin: 3px 0 0; padding: 8px 10px; border-radius: 3px 9px 9px 9px; background: white; font-size: 12px; line-height: 1.48; overflow-wrap: anywhere; }
.game-chat-slot .chat-message p { background: #34342e; }
.chat-message.is-self strong { color: #a24fd7; }
.chat-message.is-self p { margin-left: auto; border-radius: 9px 3px 9px 9px; background: #e3e9ff; }
.game-chat-slot .chat-message.is-self p { background: #405dbd; }
.chat-form { display: grid; grid-template-columns: 1fr 34px; gap: 6px; margin-top: auto; padding: 8px; border-top: 1px solid rgba(23,23,17,.13); }
.game-chat-slot .chat-form { border-top-color: #3e3e38; }
.chat-form input { min-width: 0; height: 34px; border: 1px solid rgba(23,23,17,.25); border-radius: 8px; outline: none; background: white; padding: 0 10px; font-size: 11px; }
.game-chat-slot .chat-form input { border-color: #55554d; background: #292924; color: white; }
.chat-form input:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(79,124,255,.15); }
.chat-form button { width: 34px; height: 34px; border: 1px solid var(--ink); border-radius: 8px; background: var(--lime); color: var(--ink); cursor: pointer; font: 900 17px/1 var(--latin); }

.mobile-controls { display: none; grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(2, 46px); justify-content: center; gap: 4px; margin-top: 10px; }
.mobile-controls button { border: 1px solid #5a5a54; border-radius: 8px; background: #2a2a25; color: white; font: 800 20px/1 var(--latin); touch-action: none; }
.mobile-controls button[data-dir="up"] { grid-column: 2; }
.mobile-controls button[data-dir="left"] { grid-column: 1; grid-row: 2; }
.mobile-controls button[data-dir="down"] { grid-column: 2; grid-row: 2; }
.mobile-controls button[data-dir="right"] { grid-column: 3; grid-row: 2; }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px); z-index: 100; min-width: 220px; max-width: calc(100vw - 30px); padding: 11px 15px; border: 1.5px solid var(--ink); border-radius: 10px; background: var(--paper); color: var(--ink); box-shadow: 5px 5px 0 var(--ink); text-align: center; font-weight: 700; opacity: 0; pointer-events: none; transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.loading-overlay { position: fixed; inset: 0; z-index: 200; display: grid; place-content: center; justify-items: center; gap: 15px; background: rgba(245,239,223,.9); backdrop-filter: blur(6px); }
.loader { width: 42px; height: 42px; border: 5px solid var(--ink); border-top-color: var(--lime); border-radius: 50%; animation: spin .8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { transform: translate(-50%,-50%) scale(.4); opacity: 0; } to { transform: translate(-50%,-50%) scale(1); opacity: 1; } }

@media (max-width: 1100px) {
  .game-layout { display: flex; flex-direction: column; }
  .tool-panel { display: grid; grid-template-columns: minmax(300px, .85fr) minmax(380px, 1.15fr); gap: 12px; max-height: none; overflow: visible; }
  .game-chat-slot { margin-top: 0; }
}

@media (min-width: 781px) and (max-width: 1100px) {
  .game-header.has-result-actions { min-height: 100px; }
  .game-header.has-result-actions .timer-wrap { top: 0; transform: translateX(-50%); }
  .game-header.has-result-actions .result-header-actions { position: absolute; right: 4px; top: 52px; }
}

@media (max-width: 1000px) {
  .hero { grid-template-columns: 1fr 420px; gap: 45px; }
  .hero h1 { font-size: clamp(56px,8vw,78px); }
  .lobby-layout { grid-template-columns: 1fr 330px; }
  .settings-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 780px) {
  .home-screen, .room-screen { padding: 20px 16px; }
  .hero { grid-template-columns: 1fr; gap: 32px; align-items: start; padding: 55px 0 50px; }
  .hero h1 { font-size: clamp(54px,16vw,80px); }
  .hero-description { margin-top: 22px; }
  .entry-card { max-width: 520px; width: calc(100% - 10px); }
  .home-footer { display: none; }
  .lobby-layout { grid-template-columns: 1fr; }
  .room-header { align-items: flex-start; gap: 15px; }
  .room-code-box { display: grid; grid-template-columns: auto 1fr; gap: 5px 10px; }
  .room-code-box button { grid-column: 1/-1; }
  .game-screen { padding: 11px 8px 18px; }
  .game-header { flex-wrap: wrap; margin-bottom: 9px; }
  .game-brand { font-size: 16px; }
  .round-chip { display: none; }
  .timer-wrap { min-width: 145px; }
  .timer-wrap > strong { font-size: 20px; }
  .timer-wrap { top: 0; transform: translateX(-50%); }
  .result-header-actions { order: 3; width: 100%; justify-content: center; margin: 52px 0 0; }
  .game-layout { display: flex; flex-direction: column; }
  .tool-panel { display: block; order: 2; }
  #hiderTools { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; align-items: start; }
  #hiderTools .role-card { grid-column: 1; }
  #hiderTools .hider-guide-toggle { grid-column: 1; }
  #hiderTools .tool-section { grid-column: 2; grid-row: 1/4; margin: 0; }
  #hiderTools .lock-button, #hiderTools .key-hint { grid-column: 1; }
  #avatarCanvas { width: 105px; height: 131px; }
  .mobile-controls { display: grid; }
  .key-hint { display: none; }
  .game-chat-slot .chat-panel { min-height: 300px; }
  .game-chat-slot .chat-messages { height: 215px; }
}

@media (max-width: 480px) {
  .brand-row .connection-pill { font-size: 0; padding: 9px; }
  .hero { padding-top: 42px; }
  .entry-panel { padding-left: 5px; padding-right: 5px; }
  .room-header .brand { font-size: 0; }
  .map-card, .players-card { padding: 16px; }
  .avatar-shape-picker > div:first-child { align-items: flex-start; flex-direction: column; }
  #hiderTools { grid-template-columns: 1fr; }
  #hiderTools .role-card, #hiderTools .hider-guide-toggle, #hiderTools .tool-section, #hiderTools .lock-button { grid-column: 1; grid-row: auto; }
  #avatarCanvas { width: 120px; height: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
