:root {
  color-scheme: light;
  --bg: #f4efe6;
  --panel: rgba(255, 250, 242, 0.78);
  --panel-strong: #fffaf2;
  --text: #1f2a2c;
  --muted: #697779;
  --primary: #0b7a75;
  --primary-dark: #075f5b;
  --accent: #f28482;
  --shadow: 0 22px 50px rgba(54, 44, 31, 0.14);
  --line: rgba(31, 42, 44, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "PingFang SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(242, 132, 130, 0.18), transparent 30%),
    radial-gradient(circle at right, rgba(11, 122, 117, 0.15), transparent 28%),
    linear-gradient(135deg, #f8f2e9 0%, #efe7da 52%, #e8dcc9 100%);
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.hero {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.28em;
  font-size: 12px;
  color: var(--primary);
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(36px, 5vw, 64px);
  line-height: 1;
}

.subtitle {
  margin: 12px 0 0;
  max-width: 640px;
  color: var(--muted);
  font-size: 17px;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(18px);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.controls {
  padding: 20px;
  display: grid;
  gap: 16px;
  margin-bottom: 20px;
}

.field-group {
  display: grid;
  gap: 8px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label,
.muted {
  font-size: 13px;
  color: var(--muted);
}

input,
button {
  font: inherit;
}

input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.join-box {
  display: flex;
  gap: 10px;
  flex: 1;
}

button {
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.primary,
#join-room {
  background: var(--primary);
  color: white;
  font-weight: 700;
}

.primary:hover,
#join-room:hover {
  background: var(--primary-dark);
}

.ghost {
  background: rgba(11, 122, 117, 0.08);
  color: var(--primary-dark);
}

.status-text {
  margin: 0;
  color: var(--muted);
}

.grid-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
}

.sidebar,
.board-panel {
  padding: 18px;
}

.sidebar {
  display: grid;
  gap: 16px;
  align-content: start;
}

.room-card,
.meta-card,
.skills-card,
.players-card,
.tips-card {
  background: var(--panel-strong);
  border-radius: 18px;
  padding: 16px;
  border: 1px solid rgba(31, 42, 44, 0.06);
}

.room-card {
  display: grid;
  gap: 10px;
}

.room-card strong,
.meta-card strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

.meta-card {
  display: grid;
  gap: 14px;
}

.players-card h2,
.skills-card h2,
.tips-card h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.skill-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
}

.skill-row + .skill-row {
  border-top: 1px solid rgba(31, 42, 44, 0.08);
}

#players {
  display: grid;
  gap: 10px;
}

.player-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  background: rgba(11, 122, 117, 0.06);
}

.player-row.me {
  outline: 2px solid rgba(11, 122, 117, 0.18);
}

.player-name {
  font-weight: 700;
}

.player-sub {
  font-size: 12px;
  color: var(--muted);
}

.player-score {
  text-align: right;
  font-size: 14px;
}

.board-panel {
  overflow: auto;
}

.board {
  display: grid;
  gap: 6px;
  width: fit-content;
  min-width: 100%;
  justify-content: center;
}

.cell {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid rgba(31, 42, 44, 0.08);
  background: linear-gradient(180deg, #fff 0%, #efe7db 100%);
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  place-items: center;
  font-weight: 800;
  user-select: none;
}

.cell:hover {
  transform: none;
  background: linear-gradient(180deg, #fff8f1 0%, #ece1d2 100%);
}

.cell.revealed {
  background: #fffaf2;
}

.cell.mine {
  background: linear-gradient(180deg, #f7b3b1 0%, #f28482 100%);
}

.cell.shielded {
  background: linear-gradient(180deg, #d8d8d8 0%, #a8a8a8 100%);
  color: #3a3a3a;
  cursor: help;
}

.cell.decoy.revealed {
  background: linear-gradient(180deg, #fff4d6 0%, #f5d98a 100%);
}

.cell.scanned {
  box-shadow: inset 0 0 0 2px rgba(11, 122, 117, 0.45);
}

.cell.flagged {
  background: linear-gradient(180deg, #dff5f4 0%, #bce8e5 100%);
}

.cell.adj-1 { color: #0b7a75; }
.cell.adj-2 { color: #32612d; }
.cell.adj-3 { color: #a83b33; }
.cell.adj-4 { color: #6d3bb0; }
.cell.adj-5 { color: #b45c00; }
.cell.adj-6 { color: #0c5f88; }
.cell.adj-7 { color: #5d2e2d; }
.cell.adj-8 { color: #222; }

.side-tab {
  position: fixed;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  width: 32px;
  height: 140px;
  padding: 0;
  border: 0;
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.18em;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  cursor: pointer;
  user-select: none;
  z-index: 25;
  box-shadow: 0 8px 22px rgba(11, 122, 117, 0.28);
  transition: background 160ms ease, transform 160ms ease;
}

.side-tab:hover {
  background: var(--primary-dark);
  transform: translateY(-50%);
}

.combined-tab {
  left: 0;
  border-radius: 0 12px 12px 0;
}

.side-panel {
  position: fixed;
  width: 300px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(18px);
  border-radius: 20px;
  box-shadow: var(--shadow);
  transition: transform 280ms ease, box-shadow 280ms ease;
  z-index: 20;
  overflow: hidden;
}

.combined-panel {
  left: 0;
  top: 50%;
  transform: translate(-100%, -50%);
}

.combined-panel.expanded {
  transform: translate(40px, -50%);
  box-shadow: 0 28px 60px rgba(54, 44, 31, 0.22);
}

.side-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 16px 16px 14px;
  gap: 10px;
}

.panel-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(11, 122, 117, 0.08);
  border-radius: 12px;
}

.panel-tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.panel-tab:hover {
  color: var(--text);
}

.panel-tab.active {
  background: var(--primary);
  color: white;
}

.panel-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  flex: 1;
}

.panel-pane[hidden] {
  display: none;
}

.side-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.chat-list {
  list-style: none;
  margin: 0;
  padding: 4px 4px 4px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
  flex: 1;
  max-height: 50vh;
  scrollbar-gutter: stable;
}

.chat-list li {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(31, 42, 44, 0.08);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}

.chat-list li.self {
  background: rgba(11, 122, 117, 0.12);
  border-color: rgba(11, 122, 117, 0.25);
}

.chat-list .chat-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}

.chat-list .chat-name {
  font-weight: 700;
  color: var(--primary-dark);
}

.chat-list .chat-text {
  white-space: pre-wrap;
}

.chat-form,
.todo-form {
  display: flex;
  gap: 6px;
}

.chat-form input,
.todo-form input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(31, 42, 44, 0.18);
  font: inherit;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
}

.chat-form input:focus,
.todo-form input:focus {
  outline: 2px solid rgba(11, 122, 117, 0.4);
  outline-offset: 1px;
}

.chat-form input:disabled,
.todo-form input:disabled {
  background: rgba(255, 255, 255, 0.5);
  color: var(--muted);
}

.chat-form button,
.todo-form button {
  padding: 8px 12px;
  font-size: 13px;
}

.chat-form button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.strong-notify {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.strong-notify input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
}

.strong-notify[data-state="granted"] {
  color: var(--primary-dark);
}

.strong-notify[data-state="denied"] {
  color: #a83b33;
}

.todo-list {
  list-style: none;
  margin: 0;
  padding: 4px 4px 4px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
  flex: 1;
  max-height: 50vh;
  scrollbar-gutter: stable;
}

.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(31, 42, 44, 0.08);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.4;
}

.todo-item.done {
  background: rgba(11, 122, 117, 0.08);
  border-color: rgba(11, 122, 117, 0.2);
}

.todo-item.done .todo-text {
  text-decoration: line-through;
  color: var(--muted);
}

.todo-check {
  margin-top: 2px;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  cursor: pointer;
}

.todo-text {
  flex: 1;
  word-break: break-word;
  white-space: pre-wrap;
}

.todo-time {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

.todo-delete {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  flex-shrink: 0;
}

.todo-delete:hover {
  color: #a83b33;
  transform: none;
}

.toast-stack {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 30;
  pointer-events: none;
  max-width: calc(100vw - 48px);
}

.toast-card {
  pointer-events: auto;
  width: 320px;
  max-width: 100%;
  background: var(--panel-strong);
  border: 1px solid rgba(31, 42, 44, 0.12);
  border-left: 4px solid var(--primary);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 18px 38px rgba(54, 44, 31, 0.22);
  cursor: pointer;
  animation: toast-in 220ms ease both;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toast-card.leaving {
  animation: toast-out 220ms ease both;
}

.toast-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.toast-name {
  font-weight: 700;
  color: var(--primary-dark);
}

.toast-time {
  color: var(--muted);
  margin-right: auto;
}

.toast-close {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
}

.toast-close:hover {
  color: #a83b33;
  transform: none;
}

.toast-body {
  font-size: 14px;
  color: var(--text);
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}

@keyframes toast-in {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes toast-out {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(8px); opacity: 0; }
}

.log-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 360px;
  max-width: calc(100vw - 48px);
  background: rgba(20, 24, 28, 0.92);
  color: #d8e0e4;
  border-radius: 12px;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.35);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
  font-size: 12px;
  z-index: 28;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.log-panel.collapsed .log-list {
  display: none;
}

.log-panel.collapsed {
  width: auto;
}

.log-panel.collapsed .log-actions {
  margin-left: 0;
}

.log-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  user-select: none;
}

.log-panel.collapsed .log-header {
  border-bottom: 0;
}

.log-title {
  font-weight: 700;
  font-size: 12px;
  color: #f0f4f6;
  letter-spacing: 0.05em;
}

.log-count {
  background: rgba(11, 122, 117, 0.4);
  color: #c4f1ee;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 10px;
  font-weight: 600;
  min-width: 22px;
  text-align: center;
}

.log-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.log-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 0;
  color: #d8e0e4;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}

.log-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: none;
}

.log-list {
  list-style: none;
  margin: 0;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 40vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.log-item {
  display: grid;
  grid-template-columns: 60px 50px 1fr;
  gap: 6px;
  align-items: baseline;
  font-size: 11px;
  line-height: 1.45;
  padding: 2px 4px;
  border-radius: 4px;
  word-break: break-word;
  white-space: pre-wrap;
}

.log-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.log-time {
  color: #7e8a92;
  font-size: 10px;
}

.log-level {
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  text-align: center;
  border-radius: 4px;
  padding: 0 4px;
}

.log-level.info {
  background: rgba(11, 122, 117, 0.25);
  color: #7ee5df;
}

.log-level.warn {
  background: rgba(255, 184, 0, 0.18);
  color: #ffcb66;
}

.log-level.error {
  background: rgba(242, 132, 130, 0.22);
  color: #ff9d97;
}

.log-message {
  color: #d8e0e4;
}

.log-data {
  grid-column: 3;
  color: #8a9aa3;
  font-size: 10.5px;
  word-break: break-all;
  padding-left: 4px;
}

@media (max-width: 920px) {
  .grid-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 2;
  }

  .board-panel {
    order: 1;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 20px;
  }

  .actions,
  .join-box {
    flex-direction: column;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .cell {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }
}
