:root {
  --bg: #0f1220;
  --panel: #1b1f33;
  --border: #32374f;
  --text: #e6e9f5;
  --muted: #8b91ad;
  --red: #e05a5a;
  --green: #4fc07a;
  --accent: #6ea8ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

#layout { display: flex; height: 100vh; overflow: hidden; }

#content { flex: 1; min-width: 0; min-height: 0; padding: 16px; display: flex; flex-direction: column; }

#chat-panel {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--panel);
  min-height: 100vh;
}
#chat-panel.hidden { display: none; }

.chat-title { margin: 0; padding: 14px 16px; border-bottom: 1px solid var(--border); }

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-msg {
  align-self: flex-start;
  max-width: 82%;
  line-height: 1.4;
  font-size: 14px;
  background: #22263e;
  border-radius: 10px;
  padding: 6px 10px;
}
.chat-msg .who { color: var(--accent); font-weight: 600; }
.chat-msg.mine {
  align-self: flex-end;
  background: #1f3a2c;
}
.chat-msg.mine .who { color: var(--green); }
.chat-msg .when { color: var(--muted); font-size: 11px; margin-left: 6px; }
.chat-msg .body { word-wrap: break-word; overflow-wrap: anywhere; }

#chat-input-row {
  display: flex;
  border-top: 1px solid var(--border);
  padding: 8px;
  gap: 8px;
}
#chat-input {
  flex: 1;
  min-width: 0;
  padding: 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #12152a;
  color: var(--text);
  font-size: 14px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.header-right { display: flex; align-items: center; gap: 12px; }

h1 { font-size: 22px; margin: 0; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }

.hidden { display: none !important; }

.screen { max-width: 960px; margin: 0 auto; }

#game-screen {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  max-width: 420px;
  margin: 40px auto;
}

.card label { display: block; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
.card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #12152a;
  color: var(--text);
  font-size: 16px;
}

button {
  background: var(--accent);
  color: #0b0e1c;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: .4; cursor: not-allowed; }
button.secondary { background: var(--border); color: var(--text); }

.error { color: var(--red); font-size: 14px; margin-top: 10px; min-height: 18px; }
.pending { color: var(--accent); font-size: 14px; margin-top: 10px; }

.card select, .host-panel select {
  padding: 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #12152a;
  color: var(--text);
  font-size: 14px;
  margin-left: 6px;
}

.host-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
}
.host-panel label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.join-req {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 14px;
}

#room-badge { color: var(--muted); font-size: 14px; }
#player-badge { color: var(--text); font-size: 14px; }
.turn-you { color: #e0c54a; }

#lobby-players { list-style: none; padding: 0; margin: 0 0 16px; }
#lobby-players li { padding: 8px 10px; border-bottom: 1px solid var(--border); }

#status {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.5;
}

.proposal {
  background: #2a2340;
  border: 1px solid #5c4d8a;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 14px;
}

#columns { display: flex; gap: 16px; align-items: stretch; flex: 1; min-height: 0; }
#board-panel, #hand-panel {
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#board, #hand {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.tile {
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  border-left: 5px solid var(--border);
  background: #12152a;
  cursor: default;
  line-height: 1.45;
}
.tile.red { border-left-color: var(--red); }
.tile.green { border-left-color: var(--green); }
.tile.proposed { border-left-color: #e0c54a; }
.tile .candidate { color: #e0c54a; }
.tile .noncandidate { color: #6b7080; }
.tile .phrase { display: block; }
.tile .tag { color: var(--muted); font-size: 11px; }

#board.dragging .tile.drop-target:hover { outline: 2px solid var(--accent); background: #1a2038; }

#hand .tile[draggable="true"] { cursor: grab; }
#hand .tile.in-bag { opacity: .45; }

#hand-count { color: var(--muted); font-weight: 400; }

.row { display: flex; gap: 8px; }

#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
#modal-overlay.hidden { display: none; }
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  min-width: 280px;
  max-width: 90%;
  text-align: center;
}
.gc-target { font-weight: 600; margin: 0 0 4px; }
.gc-hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.gc-phrase {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  background: #12152a;
  color: #e0c54a;
  border: 1px solid #e0c54a;
  border-radius: 8px;
  padding: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.gc-phrase:hover { background: #1a2038; }

.announce {
  background: #3a2f1e;
  border: 2px solid #c8b06a;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-weight: 600;
}

#exchange-panel { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.bag {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  min-height: 56px;
}
.bag:hover { border-color: var(--accent); background: #1a2038; }
.bag-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bag-icon { font-size: 22px; }
.bag-label { color: var(--muted); font-size: 13px; }
.bag-count { color: var(--accent); font-size: 14px; font-weight: 600; }
.bag-actions { margin-left: auto; display: inline-flex; gap: 6px; }
.small { padding: 5px 10px; font-size: 13px; }
#bag-tiles { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
#bag-tiles .tile { margin-bottom: 0; }
.bag-tile { cursor: pointer; }

.vote { font-size: 16px; margin-right: 8px; }
.vote.up { background: var(--green); }
.vote.down { background: var(--red); color: #fff; }

.voting-group {
  border: 2px solid #c8b06a;
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
  background: #221d33;
}
.voting-group .inline-vote { margin-bottom: 0; }

.inline-vote {
  background: #2a2340;
  border: 2px solid #c8b06a;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.inline-vote .iv-title { font-weight: 700; margin: 0 0 6px; }
.inline-vote .iv-title.ok { color: var(--green); }
.inline-vote .iv-title.bad { color: var(--red); }
.inline-vote .iv-count { color: var(--muted); font-size: 13px; margin: 0 0 4px; }
.inline-vote .iv-reject { color: var(--red); font-size: 13px; margin: 0; }
.inline-vote button { margin-top: 4px; }

#message { margin-top: 12px; }

#voice-panel {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}
#voice-panel button {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.2;
}
#voice-panel button.on { background: #3dbb6d; }
#voice-panel button.off { background: #e57373; }
#voice-panel .btn-line1 { font-weight: 700; }
#voice-panel .btn-line2 { font-size: 11px; opacity: 0.85; }
.meter {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 5px;
  width: 0%;
  background: #0a5a2a;
  transition: width 0.08s linear;
}

@media (max-width: 720px) {
  #columns { flex-direction: column; }
  #layout { flex-direction: column; }
  #chat-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: 45vh;
    min-height: 0;
    border-right: 0;
    border-top: 1px solid var(--border);
    z-index: 20;
  }
  #content { padding-bottom: 46vh; }
}

/* ---- game-lobby landing ---- */
.muted { color: var(--muted); }
.primary { display: block; width: 100%; }

.gl-hero { text-align: center; padding: 16px 0; }
.gl-hero h2 { font-size: 26px; margin: 0 0 4px; }
.gl-tag { color: var(--muted); margin: 0 0 12px; }
.gl-testimonials p { font-style: italic; margin: 4px 0; }
.gl-links { margin: 14px 0 0; }
.gl-links a { color: var(--accent); }

.gl-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.gl-panel h3 { margin: 0 0 10px; }
.gl-panel h4 { margin: 16px 0 8px; }
.gl-panel label { display: block; margin-bottom: 10px; font-size: 14px; color: var(--muted); }
.gl-panel input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #12152a;
  color: var(--text);
  font-size: 15px;
}

.gl-room {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #12152a;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 14px;
  margin-bottom: 6px;
}
.gl-manual { display: flex; gap: 8px; margin-top: 12px; }
.gl-manual input { flex: 1; margin-top: 0; }

.scores { width: 100%; border-collapse: collapse; font-size: 14px; }
.scores th, .scores td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.scores th { color: var(--muted); font-weight: 600; }

/* ---- record score ---- */
.record-score {
  background: #2a2340;
  border: 2px solid #c8b06a;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.rs-title { font-weight: 700; margin: 0 0 8px; }
.rs-check { display: flex; align-items: center; gap: 6px; font-size: 14px; margin-bottom: 8px; }
.rs-ok { color: var(--green); }
.rs-err { color: var(--red); }
