:root {
  --brand-navy: #0f172a;
  --brand-blue: #1d4ed8;
  --brand-gold: #f59e0b;
  --brand-soft: #eff6ff;
  --active-light: #ead8b8;
  --active-dark: #b88a5a;
  --selected: #fff176;
  --move: rgba(30, 120, 60, 0.36);
  --capture: rgba(200, 40, 40, 0.48);
  --danger: rgba(220, 38, 38, 0.58);
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --red: #f87171;
  --blue: #60a5fa;
  --yellow: #facc15;
  --green: #4ade80;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, sans-serif;
  background: radial-gradient(circle at top left, #eff6ff 0%, #f8fafc 42%, #dbeafe 100%);
  color: var(--text);
}

a { color: inherit; text-decoration: none; }
code { background: #eef2ff; padding: 2px 5px; border-radius: 6px; }

.landing {
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
  padding: 36px 0;
  display: grid;
  gap: 20px;
}

.hero-card,
.rooms-card,
.panel,
.board-wrap,
.panel-form {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.12);
}

.hero-card,
.rooms-card {
  border-radius: 28px;
  padding: clamp(22px, 4vw, 38px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand-blue);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 900;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(30px, 5vw, 56px);
  letter-spacing: -0.06em;
  line-height: 0.98;
}

h2 {
  margin: 0 0 14px;
  font-size: 20px;
  letter-spacing: -0.03em;
}

.lead,
.subtitle,
.muted,
.modal-copy {
  color: var(--muted);
  line-height: 1.55;
}

.lead { max-width: 760px; font-size: 17px; margin: 0 0 22px; }
.subtitle { margin: 0 0 18px; font-size: 14px; }
.muted { margin: 0; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.panel-form {
  border-radius: 20px;
  padding: 20px;
  box-shadow: none;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  color: #374151;
  font-size: 13px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 13px;
  font: inherit;
  outline: none;
}

input:focus,
select:focus { border-color: var(--brand-blue); box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12); }

select { background: #ffffff; cursor: pointer; }

button {
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 900;
  cursor: pointer;
  background: var(--brand-navy);
  color: white;
  transition: transform 0.08s ease, opacity 0.12s ease;
}

button:hover { opacity: 0.9; }
button:active { transform: translateY(1px); }
button.secondary { background: #e5e7eb; color: #111827; }
button.small { padding: 8px 10px; font-size: 12px; }
button.danger { background: #dc2626; color: #ffffff; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.alert,
.notice {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #78350f;
  border-radius: 14px;
  padding: 12px;
  line-height: 1.45;
  font-size: 13px;
}

.notice { margin: 8px 0 14px; }
.notice.error { background: #fef2f2; border-color: #fecaca; color: #7f1d1d; }
.notice.ok { background: #ecfdf5; border-color: #bbf7d0; color: #14532d; }

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head span { color: var(--muted); font-size: 13px; }

.room-list { display: grid; gap: 10px; }
.room-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: #f9fafb;
}
.room-row:hover { border-color: #bfdbfe; background: #eff6ff; }
.room-main {
  flex: 1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-width: 220px;
}
.room-row strong { display: block; }
.room-row em { display: block; color: var(--muted); font-size: 13px; margin-top: 3px; font-style: normal; }
.room-row b { color: var(--brand-blue); }
.delete-help { margin: -4px 0 12px; font-size: 13px; }
.delete-room-form {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: min(310px, 100%);
}
.delete-room-form input {
  max-width: 150px;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 13px;
}


.game-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

.app {
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: minmax(520px, 740px) minmax(280px, 1fr);
  gap: 22px;
  align-items: start;
}

.board-wrap {
  border-radius: 24px;
  padding: 18px;
}

.room-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
}

.room-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.board {
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  overflow: hidden;
  background: #374151;
  border: 8px solid var(--brand-navy);
  user-select: none;
}

.square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(20px, 3.8vw, 42px);
  transition: filter 0.12s ease, transform 0.08s ease;
}

.square.active { cursor: pointer; }
.square.active:hover { filter: brightness(1.07); }
.square.light { background: var(--active-light); }
.square.dark { background: var(--active-dark); }
.square.inactive { background: #374151; pointer-events: none; }
.square.red-zone.light { background: #fee2e2; }
.square.red-zone.dark { background: #fecaca; }
.square.blue-zone.light { background: #dbeafe; }
.square.blue-zone.dark { background: #bfdbfe; }
.square.yellow-zone.light { background: #fef9c3; }
.square.yellow-zone.dark { background: #fde68a; }
.square.green-zone.light { background: #dcfce7; }
.square.green-zone.dark { background: #bbf7d0; }
.square.selected { background: var(--selected); }
.square.king-danger { box-shadow: inset 0 0 0 999px var(--danger); }
.square.locked { cursor: not-allowed; }

.hint::after {
  content: "";
  position: absolute;
  width: 32%;
  height: 32%;
  border-radius: 999px;
  background: var(--move);
}

.capture-hint::after {
  content: "";
  position: absolute;
  width: 82%;
  height: 82%;
  border-radius: 999px;
  border: 4px solid var(--capture);
}

.piece {
  line-height: 1;
  transform: translateY(-1px);
  font-weight: 900;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.42));
  -webkit-text-stroke: 1.4px rgba(255,255,255,0.92);
  paint-order: stroke fill;
}

.piece.red { color: var(--red); }
.piece.blue { color: var(--blue); }
.piece.yellow { color: var(--yellow); -webkit-text-stroke: 1.3px rgba(120, 53, 15, 0.75); }
.piece.green { color: var(--green); }

.coord {
  position: absolute;
  font-size: 9px;
  font-weight: bold;
  color: rgba(17,24,39,0.55);
  pointer-events: none;
}

.rank { top: 3px; left: 4px; }
.file { right: 4px; bottom: 2px; }

.panel {
  border-radius: 24px;
  padding: 22px;
}

.panel h1 { font-size: 28px; }

.status-card {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 14px;
}
.status-card.compact { padding: 11px 14px; }

.label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 900;
}

#status {
  font-size: 18px;
  font-weight: 900;
  line-height: 1.35;
}

#mySeat { font-weight: 900; }

.team-color { display: inline-flex; align-items: center; gap: 4px; margin-right: 6px; font-weight: 800; }

.turn-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: -1px;
  border: 1px solid rgba(0,0,0,0.25);
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}

.players {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0 16px;
}

.player-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: #f9fafb;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.player-card.current { outline: 3px solid rgba(17, 24, 39, 0.12); }
.player-card.out { opacity: 0.45; text-decoration: line-through; }
.player-card.empty { opacity: 0.65; }
.player-card em { font-style: normal; color: var(--muted); font-weight: 700; font-size: 12px; }

.moves {
  max-height: 300px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f9fafb;
  padding: 10px;
  font-family: Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
}

.move-row {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 8px;
}

.move-row:nth-child(even) { background: #ffffff; }
.move-no { color: var(--muted); }



.voice-card {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #f8fafc;
  padding: 12px;
}

.voice-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.voice-head .label { margin-bottom: 0; }

.voice-status {
  border-radius: 999px;
  padding: 4px 8px;
  background: #e5e7eb;
  color: #374151;
  font-size: 12px;
  font-weight: 900;
}

.voice-status.live {
  background: #dcfce7;
  color: #166534;
}

.voice-status.error {
  background: #fee2e2;
  color: #991b1b;
}

.voice-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 9px;
}

.voice-participants {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  padding: 9px;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.voice-person {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text);
  font-weight: 800;
}

.voice-person small {
  color: var(--muted);
  font-weight: 700;
}

.remote-audio {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.remote-audio audio {
  width: 100%;
  height: 34px;
}

.voice-hint {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.chat-card {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #f9fafb;
  padding: 12px;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.chat-head .label { margin-bottom: 0; }

.chat-messages {
  height: 190px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  padding: 9px;
  display: grid;
  align-content: start;
  gap: 8px;
}

.chat-empty {
  color: var(--muted);
  font-size: 13px;
}

.chat-message {
  border-bottom: 1px solid #f3f4f6;
  padding-bottom: 7px;
}

.chat-message:last-child { border-bottom: 0; padding-bottom: 0; }

.chat-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
  font-size: 12px;
}

.chat-name {
  font-weight: 900;
  color: var(--brand-navy);
}

.chat-time { color: var(--muted); white-space: nowrap; }

.chat-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.4;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 9px;
}

.chat-form input { padding: 10px 11px; }
.chat-form button { padding: 10px 13px; }

.chat-hint {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.rules {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}

.promotion-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(17, 24, 39, 0.55);
  z-index: 10;
  padding: 20px;
}

.promotion-modal.show { display: flex; }

.promotion-box {
  background: white;
  padding: 20px;
  border-radius: 18px;
  width: min(380px, 100%);
  text-align: center;
  box-shadow: 0 30px 90px rgba(0,0,0,0.3);
}

.join-box { display: grid; gap: 10px; text-align: left; }
.join-box .promotion-title { text-align: left; margin-bottom: 0; }
.modal-copy { margin: 0 0 6px; font-size: 14px; }
.modal-input { margin-bottom: 2px; }

.promotion-title {
  font-weight: 900;
  font-size: 20px;
  margin-bottom: 14px;
}

.promotion-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.promo-btn {
  font-size: 34px;
  padding: 12px 0;
  background: #f3f4f6;
  color: #111827;
  border: 1px solid #e5e7eb;
}

@media (max-width: 720px) {
  .room-row { align-items: stretch; flex-direction: column; }
  .room-main { width: 100%; }
  .delete-room-form { justify-content: stretch; width: 100%; min-width: 0; }
  .delete-room-form input { max-width: none; flex: 1; }
}

@media (max-width: 900px) {
  .game-page { padding: 12px; align-items: start; }
  .app { grid-template-columns: 1fr; }
  .panel { order: -1; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .app { gap: 12px; }
  .board-wrap { padding: 8px; border-radius: 18px; }
  .board { border-width: 5px; border-radius: 12px; }
  .panel { padding: 16px; }
  .players { grid-template-columns: 1fr; }
  .controls { grid-template-columns: 1fr; }
  .chat-form { grid-template-columns: 1fr; }
  .voice-controls { grid-template-columns: 1fr; }
  .hero-card, .rooms-card { padding: 18px; border-radius: 20px; }
}
