:root {
  --bg-dark: #0e1017;
  --bg-panel: #161923;
  --bg-card: #1e2230;
  --bg-hover: #272c3f;
  --border: #2e344b;
  --gold: #d4af37;
  --gold-light: #f0cf65;
  --crimson: #e63946;
  --emerald: #2a9d8f;
  --text-main: #f1f3f9;
  --text-muted: #9aa3bd;
  --font-serif: 'Noto Serif KR', Georgia, serif;
  --font-sans: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
}

html {
  -webkit-text-size-adjust: 100%;
}

button, .cell, .note-row, .char-card, .tabbar-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: radial-gradient(circle at top, #181c2b 0%, var(--bg-dark) 75%);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: rgba(14, 16, 23, 0.9);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-badge {
  background: linear-gradient(135deg, var(--gold), #a8821c);
  color: #111;
  font-weight: 900;
  font-size: 0.85rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  letter-spacing: 0.05em;
}

.app-header h1 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  color: var(--gold-light);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.room-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.3rem 0.7rem;
  border-radius: 8px;
  font-size: 0.85rem;
}

.room-badge strong {
  color: var(--gold-light);
  letter-spacing: 0.08em;
}

/* Buttons */
.btn {
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-xs {
  padding: 0.32rem 0.65rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, #c92a36, var(--crimson));
  color: #fff;
  box-shadow: 0 4px 14px rgba(230, 57, 70, 0.3);
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold), #b89122);
  color: #111;
}
.btn-gold:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-emerald {
  background: linear-gradient(135deg, #2a9d8f, #21867a);
  color: #fff;
}
.btn-emerald:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-danger {
  background: #7f1d1d;
  border: 1px solid #ef4444;
  color: #fecaca;
}
.btn-danger:hover:not(:disabled) {
  background: #991b1b;
}

.btn-ghost {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
}

.btn-outline {
  background: transparent;
  border: 1px dashed var(--gold);
  color: var(--gold-light);
}
.btn-outline:hover:not(:disabled) {
  background: rgba(212, 175, 55, 0.12);
}

/* Screens */
.screen {
  display: none;
  flex: 1;
}
.screen.active {
  display: flex;
  flex-direction: column;
}

/* Lobby */
.lobby-hero {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.hero-card {
  max-width: 720px;
  width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.hero-eyebrow {
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  margin-bottom: 0.6rem;
}

.hero-card h2 {
  font-family: var(--font-serif);
  font-size: 1.85rem;
  margin-bottom: 0.8rem;
  line-height: 1.35;
}

.hero-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 2rem;
}

.lobby-form-grid {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.input-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

input[type="text"], select, textarea {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
}

.lobby-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 1.25rem;
  align-items: stretch;
}

.action-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
}

.action-box h3 {
  font-size: 1.05rem;
  color: var(--gold-light);
}

.action-box p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.join-row {
  display: flex;
  gap: 0.5rem;
}

.join-row input {
  flex: 1;
  min-width: 0;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.join-row .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.divider-vertical {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.status-msg {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--gold-light);
  min-height: 1.4em;
}

/* Waiting Room */
.waiting-container {
  max-width: 980px;
  width: 100%;
  margin: 1.5rem auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.waiting-header {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.badge-tag {
  background: rgba(212, 175, 55, 0.18);
  color: var(--gold-light);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 5px;
}

.gold-text {
  color: var(--gold-light);
}

.sub-text {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.waiting-invite-box {
  display: flex;
  gap: 0.5rem;
  min-width: 280px;
}

.waiting-invite-box input {
  flex: 1;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.waiting-body {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.25rem;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
}

.panel h3 {
  font-size: 1rem;
  margin-bottom: 0.85rem;
  color: var(--gold-light);
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.panel-title-row h3 {
  margin-bottom: 0;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.char-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.15s ease;
}

.char-card:hover:not(.taken) {
  border-color: var(--gold);
  background: var(--bg-hover);
}

.char-card.selected {
  border-color: var(--gold-light);
  background: rgba(212, 175, 55, 0.14);
}

.char-card.taken {
  opacity: 0.45;
  cursor: not-allowed;
}

.char-swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: #111;
}

.char-info strong {
  display: block;
  font-size: 0.92rem;
}

.char-info span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.player-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 1.25rem;
}

.player-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}

.player-item-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.mini-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(255,255,255,0.5);
}

.center-text {
  text-align: center;
}

/* Game Layout */
.game-layout {
  display: grid;
  grid-template-columns: 290px 1fr 310px;
  gap: 0.9rem;
  padding: 0.9rem;
  flex: 1;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

.sidebar-left, .sidebar-right {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.compact-panel {
  padding: 0.9rem;
}

.turn-badge {
  background: rgba(42, 157, 143, 0.2);
  color: #6ee7b7;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
}

.game-players-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.gp-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0.65rem;
  border-radius: 7px;
  background: var(--bg-card);
  border: 1px solid transparent;
  font-size: 0.83rem;
}

.gp-item.active-turn {
  border-color: var(--gold-light);
  background: rgba(212, 175, 55, 0.14);
}

.gp-item.eliminated {
  opacity: 0.45;
  text-decoration: line-through;
}

/* My Cards */
.my-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.45rem;
}

.clue-card {
  background: linear-gradient(145deg, #24293a, #191d29);
  border: 1px solid #3a415c;
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
}

.clue-card-icon {
  font-size: 1.15rem;
}

.clue-card-type {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.public-cards-box {
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px dashed var(--border);
}

.tiny-label {
  font-size: 0.73rem;
  color: var(--gold-light);
  margin-bottom: 0.35rem;
}

.public-cards-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.public-chip {
  background: rgba(212, 175, 55, 0.14);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 5px;
  padding: 0.2rem 0.45rem;
  font-size: 0.75rem;
}

/* Logs & Chat */
.log-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.9rem;
  min-height: 240px;
}

.game-log-list {
  flex: 1;
  overflow-y: auto;
  max-height: 280px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-right: 0.25rem;
  margin-bottom: 0.6rem;
  font-size: 0.8rem;
}

.log-entry {
  padding: 0.4rem 0.55rem;
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
  line-height: 1.4;
}

.log-entry.system {
  color: var(--gold-light);
  background: rgba(212, 175, 55, 0.08);
}

.log-entry.secret {
  color: #6ee7b7;
  background: rgba(42, 157, 143, 0.16);
  border: 1px solid rgba(42, 157, 143, 0.35);
}

.log-entry.danger {
  color: #fca5a5;
  background: rgba(230, 57, 70, 0.14);
}

.chat-form {
  display: flex;
  gap: 0.4rem;
}

.chat-form input {
  flex: 1;
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
}

/* Center Board */
.board-center {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

.action-bar {
  width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.turn-banner {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.dice-box {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
}

.die {
  font-size: 1.2rem;
  font-weight: 800;
}

.steps-text {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--gold-light);
}

.turn-instruction {
  font-size: 0.9rem;
  font-weight: 600;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.board-wrapper {
  width: 100%;
  max-width: 660px;
  aspect-ratio: 1 / 1;
  background: #1a1612;
  border: 3px solid #4a3b2c;
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.65);
}

.mansion-board {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  gap: 1px;
  background: #2b241d;
  position: relative;
}

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  font-size: 0.65rem;
}

.cell.hallway {
  background: #d8c7a8;
  border-radius: 2px;
}

.cell.start-spot {
  background: #cbb48c;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25);
}

.cell.room {
  background: #332a24;
  border: none;
}

.cell.room.door {
  background: #5c4632;
  box-shadow: inset 0 0 0 2px #d4af37;
}

.cell.cellar {
  background: #1c1714;
}

.cell.reachable {
  cursor: pointer;
  box-shadow: inset 0 0 0 2px #10b981, 0 0 8px rgba(16, 185, 129, 0.75);
  background-color: rgba(16, 185, 129, 0.38) !important;
  z-index: 4;
}

.cell.reachable:hover {
  background-color: rgba(16, 185, 129, 0.65) !important;
}

.room-label-overlay {
  position: absolute;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 3;
  color: #f4e8d1;
  text-shadow: 0 1px 4px rgba(0,0,0,0.95);
}

.room-label-overlay strong {
  font-family: var(--font-serif);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.room-label-overlay span {
  font-size: 0.62rem;
  color: var(--gold-light);
}

.tokens-holder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1px;
  z-index: 6;
  pointer-events: none;
}

.pawn-token {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid #111;
  box-shadow: 0 2px 5px rgba(0,0,0,0.85);
  transition: transform 0.2s ease;
}

.pawn-token.active-pawn {
  transform: scale(1.28);
  box-shadow: 0 0 0 2px #fff, 0 0 10px #fff;
  z-index: 8;
}

.board-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}
.legend-dot.door { background: #5c4632; border: 1px solid #d4af37; }
.legend-dot.passage { background: var(--gold); }
.legend-dot.reachable { background: #10b981; }

/* Notepad */
.notepad-panel {
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.tiny-hint {
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.notepad-content {
  max-height: 520px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.note-section-title {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--gold-light);
  background: rgba(212, 175, 55, 0.1);
  padding: 0.25rem 0.5rem;
  border-radius: 5px;
  margin-bottom: 0.25rem;
}

.note-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.28rem 0.5rem;
  border-radius: 5px;
  background: var(--bg-card);
  cursor: pointer;
  font-size: 0.82rem;
  border: 1px solid transparent;
}

.note-row:hover {
  border-color: var(--border);
}

.note-row.state-x {
  opacity: 0.5;
  text-decoration: line-through;
}

.note-row.state-check {
  background: rgba(42, 157, 143, 0.16);
  border-color: rgba(42, 157, 143, 0.4);
}

.note-row.state-star {
  background: rgba(212, 175, 55, 0.16);
  border-color: rgba(212, 175, 55, 0.45);
}

.note-mark {
  font-weight: 700;
  min-width: 24px;
  text-align: center;
}

.memo-box {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.memo-box label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.memo-box textarea {
  font-size: 0.8rem;
  resize: vertical;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 12, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 480px;
  width: 100%;
  padding: 1.6rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
}

.modal-card.danger-border {
  border-color: var(--crimson);
}

.modal-card.victory-card {
  border-color: var(--gold);
  text-align: center;
  max-width: 540px;
}

.modal-card.rules-card {
  max-width: 600px;
}

.modal-card h3, .modal-card h2 {
  font-family: var(--font-serif);
  margin-bottom: 0.6rem;
}

.modal-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1.1rem;
}

.warning-text {
  color: #fca5a5;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.3rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

.modal-footer.center {
  justify-content: center;
}

.refute-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.refute-option-btn {
  background: var(--bg-card);
  border: 2px solid var(--gold);
  border-radius: 10px;
  padding: 1rem 0.75rem;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  transition: transform 0.15s ease;
}

.refute-option-btn:hover {
  transform: translateY(-2px);
  background: rgba(212, 175, 55, 0.18);
}

.envelope-reveal {
  background: var(--bg-dark);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 1.1rem;
  margin: 1.2rem 0;
}

.envelope-reveal h4 {
  color: var(--gold-light);
  margin-bottom: 0.8rem;
  font-size: 0.95rem;
}

.solution-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}

.sol-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.rules-body {
  max-height: 60vh;
  overflow-y: auto;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-bottom: 1.2rem;
}

.rules-body h4 {
  color: var(--gold-light);
  margin-top: 0.3rem;
}

.rules-body ul, .rules-body ol {
  padding-left: 1.25rem;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 200;
}

.toast {
  background: var(--bg-card);
  border-left: 4px solid var(--gold);
  color: var(--text-main);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.6);
  font-size: 0.88rem;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   추가: 연결 상태 / 재접속 / 공통
   ========================================================================== */
.show-mobile { display: none; }

.badge-tag.off {
  background: rgba(230, 57, 70, 0.18);
  color: #fca5a5;
}

.badge-tag.me {
  background: rgba(42, 157, 143, 0.22);
  color: #6ee7b7;
}

.player-item-left {
  flex-wrap: wrap;
  row-gap: 0.25rem;
}

.char-card {
  font-family: inherit;
  color: inherit;
  text-align: left;
  width: 100%;
}

.note-row {
  width: 100%;
  color: inherit;
  font-family: inherit;
  text-align: left;
}

.conn-banner {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 150;
  background: #7c2d12;
  color: #fed7aa;
  border: 1px solid #f97316;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  max-width: calc(100% - 24px);
  text-align: center;
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: 0.75; }
}

.reconnect-card {
  text-align: center;
  max-width: 380px;
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin: 0.5rem auto 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.action-bar.my-turn {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), 0 0 18px rgba(212, 175, 55, 0.25);
}

.room-pawns {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px;
  margin-top: 3px;
}

.pawn-token.my-pawn {
  outline: 2px dashed rgba(255, 255, 255, 0.85);
  outline-offset: 1px;
}

.room-label-overlay.reachable-room strong {
  color: #6ee7b7;
}

.mobile-tabbar {
  display: none;
}

/* ==========================================================================
   Responsive — 태블릿
   ========================================================================== */
@media (max-width: 1120px) and (min-width: 901px) {
  .game-layout {
    grid-template-columns: 1fr;
  }
  .board-wrapper {
    max-width: 560px;
  }
  .waiting-body {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Responsive — 휴대폰
   ========================================================================== */
@media (max-width: 900px) {
  .hide-mobile { display: none !important; }
  .show-mobile { display: inline; }

  /* iOS 확대 방지: 입력칸 글자 16px 이상 */
  input[type="text"], select, textarea {
    font-size: 16px;
  }

  /* 헤더 */
  .app-header {
    position: static;
    padding: 0.55rem 0.75rem;
    padding-top: calc(0.55rem + env(safe-area-inset-top, 0px));
    gap: 0.5rem;
  }
  .app-header h1 {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .header-left {
    min-width: 0;
  }
  .logo-badge {
    white-space: nowrap;
  }
  body[data-screen="game"] .app-header h1,
  body[data-screen="waiting"] .app-header h1 {
    display: none;
  }
  .header-right {
    gap: 0.35rem;
  }
  .header-right .btn-xs {
    min-height: 34px;
    min-width: 34px;
  }
  .room-badge {
    padding: 0.2rem 0.3rem 0.2rem 0.55rem;
    font-size: 0.82rem;
  }

  /* 로비 */
  .lobby-hero {
    align-items: flex-start;
    padding: 1rem 0.85rem 2rem;
  }
  .hero-card {
    padding: 1.4rem 1.1rem;
    border-radius: 14px;
  }
  .hero-card h2 {
    font-size: 1.35rem;
  }
  .hero-desc {
    font-size: 0.88rem;
    margin-bottom: 1.25rem;
  }
  .lobby-actions {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.6rem;
  }
  .join-row input {
    min-width: 0;
  }
  .join-row .btn {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 0 1.2rem;
  }
  .divider-vertical {
    padding: 0.1rem 0;
  }
  .action-box {
    padding: 1rem;
  }
  .action-box .btn, .join-row .btn {
    min-height: 48px;
  }

  /* 대기실 */
  .waiting-container {
    margin: 0.75rem auto;
    padding: 0 0.75rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
    gap: 0.75rem;
  }
  .waiting-header {
    padding: 1rem;
  }
  .waiting-header h2 {
    font-size: 1.2rem;
    margin-top: 0.3rem;
  }
  .waiting-invite-box {
    min-width: 0;
    width: 100%;
    flex-direction: column;
  }
  .waiting-invite-box .btn {
    width: 100%;
    min-height: 46px;
  }
  .waiting-body {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .panel {
    padding: 1rem;
  }
  .character-grid {
    gap: 0.5rem;
  }
  .char-card {
    padding: 0.6rem;
    gap: 0.5rem;
  }
  .char-info strong {
    font-size: 0.85rem;
  }
  #btn-start-game {
    min-height: 50px;
  }

  /* 게임 화면: 한 줄 배치 + 하단 탭 */
  .game-layout {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding: 0 0.6rem calc(74px + env(safe-area-inset-bottom, 0px));
  }
  .board-center {
    order: -1;
    gap: 0.6rem;
  }
  .game-layout:not([data-tab="board"]) .board-center {
    position: sticky;
    top: 0;
    z-index: 40;
  }

  .action-bar {
    position: sticky;
    top: 0;
    z-index: 40;
    margin: 0 -0.6rem;
    width: calc(100% + 1.2rem);
    border-radius: 0 0 14px 14px;
    border-top: none;
    padding: 0.65rem 0.75rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    background: rgba(22, 25, 35, 0.97);
    backdrop-filter: blur(8px);
  }
  .turn-banner {
    gap: 0.6rem;
  }
  .turn-instruction {
    font-size: 0.9rem;
    line-height: 1.35;
  }
  .action-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.45rem;
  }
  .action-buttons:not(:has(.btn:not(.hidden))) {
    display: none;
  }
  .action-buttons .btn {
    min-height: 46px;
    font-size: 0.92rem;
  }

  .board-wrapper {
    max-width: none;
    padding: 3px;
    border-width: 2px;
    border-radius: 10px;
  }
  .board-legend {
    gap: 0.5rem 0.8rem;
    font-size: 0.72rem;
    justify-content: center;
  }
  .room-label-overlay strong {
    font-size: 0.58rem;
    line-height: 1.2;
  }
  .room-label-overlay span {
    font-size: 0.5rem;
  }
  .pawn-token {
    width: 12px;
    height: 12px;
    border-width: 1.5px;
  }

  .sidebar-left, .sidebar-right {
    gap: 0.65rem;
  }
  .gp-item {
    padding: 0.6rem 0.7rem;
    font-size: 0.9rem;
  }
  .clue-card {
    padding: 0.7rem;
    font-size: 0.92rem;
  }
  .clue-card-icon {
    font-size: 1.4rem;
  }

  .log-panel {
    min-height: calc(100dvh - 300px);
  }
  .game-log-list {
    max-height: none;
    font-size: 0.86rem;
  }
  .chat-form input {
    padding: 0.6rem 0.7rem;
  }
  .chat-form .btn {
    min-height: 44px;
    padding: 0 1rem;
  }

  .notepad-content {
    max-height: none;
  }
  .note-row {
    padding: 0.65rem 0.75rem;
    font-size: 0.95rem;
    margin-bottom: 0.3rem;
  }
  .note-mark {
    font-size: 1.05rem;
  }

  /* 탭 전환 */
  .game-layout[data-tab="board"] [data-mtab]:not([data-mtab="board"]),
  .game-layout[data-tab="cards"] [data-mtab]:not([data-mtab="cards"]),
  .game-layout[data-tab="notes"] [data-mtab]:not([data-mtab="notes"]),
  .game-layout[data-tab="log"] [data-mtab]:not([data-mtab="log"]) {
    display: none !important;
  }

  .mobile-tabbar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    background: rgba(14, 16, 23, 0.97);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    backdrop-filter: blur(8px);
  }
  .tabbar-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 0 0.45rem;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    position: relative;
    min-height: 58px;
    cursor: pointer;
  }
  .tabbar-btn .tab-icon {
    font-size: 1.3rem;
    filter: grayscale(0.7);
  }
  .tabbar-btn.active {
    color: var(--gold-light);
  }
  .tabbar-btn.active .tab-icon {
    filter: none;
  }
  .tab-dot {
    position: absolute;
    top: 7px;
    left: calc(50% + 10px);
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--crimson);
  }

  /* 모달: 아래에서 올라오는 시트 */
  .modal {
    align-items: flex-end;
    padding: 0;
  }
  .modal-card {
    max-width: none !important;
    border-radius: 18px 18px 0 0;
    padding: 1.25rem 1.1rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
    max-height: 92dvh;
    overflow-y: auto;
  }
  .modal-desc br {
    display: none;
  }
  .modal-footer {
    flex-direction: column-reverse;
  }
  .modal-footer .btn {
    width: 100%;
    min-height: 48px;
  }
  .modal-form select {
    min-height: 46px;
  }
  .refute-option-btn {
    min-height: 90px;
  }
  .rules-body {
    max-height: none;
  }

  /* 토스트는 위쪽 가운데 */
  .toast-container {
    top: calc(env(safe-area-inset-top, 0px) + 56px);
    bottom: auto;
    left: 12px;
    right: 12px;
    align-items: center;
  }
  .toast {
    width: 100%;
    max-width: 420px;
    text-align: center;
  }

  /* 터치 기기에서 hover 효과 제거 */
  .btn-primary:hover:not(:disabled),
  .refute-option-btn:hover {
    transform: none;
  }
}

@media (max-width: 380px) {
  .tabbar-btn {
    font-size: 0.66rem;
  }
  .action-buttons {
    grid-template-columns: 1fr 1fr;
  }
}
