:root {
  --bg: #12324f;
  --panel: #f7f4ec;
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #d8d2c4;
  --accent: #e8a33d;
  --danger: #b42318;
  --radius: 10px;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }

body { margin: 0; background: var(--bg); min-height: 100vh; }

a { color: inherit; }

button {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid #b9b2a2;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
button:hover:not(:disabled) { background: #fff5e0; border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); border-color: #c98622; color: #1b1300; font-weight: 600; }
button.primary:hover:not(:disabled) { background: #f0b456; }
button.small { padding: 0.15rem 0.45rem; font-size: 0.8rem; }

.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: #0b2238;
  color: #fff;
}
.topbar h1 { font-size: 1.15rem; margin: 0; flex: 1; }
.topbar a { text-decoration: none; opacity: 0.8; }
.topbar a:hover { opacity: 1; }
.topbar button { background: transparent; color: #fff; border-color: #ffffff55; }
.topbar button:hover:not(:disabled) { background: #ffffff1a; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 1rem;
  padding: 1rem;
  align-items: start;
}
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; } }

.board-wrap { position: relative; }
.hexboard { width: 100%; max-height: calc(100vh - 90px); display: block; user-select: none; touch-action: none; }
.cell { cursor: pointer; }
.cell:hover polygon { filter: brightness(1.08); }
.cell-label { font-weight: 700; pointer-events: none; font-family: ui-monospace, Menlo, monospace; }
.cell-highlight { fill: none; stroke: #fff; stroke-width: 5; stroke-dasharray: 8 5; animation: pulse 1.2s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: 0.35; } }

.draggable { cursor: grab; }
.dragging { cursor: grabbing; opacity: 0.85; filter: drop-shadow(0 4px 6px #0008); }

.sidebar { display: flex; flex-direction: column; gap: 0.75rem; }

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  box-shadow: 0 2px 8px #0004;
}
.panel h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 0.5rem; }
.row { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); font-size: 0.85rem; }

.tabs { display: flex; gap: 0.25rem; margin-bottom: 0.5rem; }
.tabs button { flex: 1; }
.tabs button.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.log { max-height: 260px; overflow-y: auto; font-size: 0.85rem; margin: 0; padding-left: 0; list-style: none; }
.log li { padding: 0.2rem 0; border-bottom: 1px solid var(--line); }
.log .round { color: var(--muted); font-size: 0.75rem; margin-right: 0.35rem; }

.rules { max-height: calc(100vh - 200px); overflow-y: auto; font-size: 0.9rem; line-height: 1.45; }
.rules h1 { font-size: 1.2rem; }
.rules h2 { font-size: 1rem; text-transform: none; letter-spacing: 0; color: var(--ink); margin-top: 1rem; }
.rules h3 { font-size: 0.95rem; }
.rules blockquote { margin: 0.5rem 0; padding: 0.4rem 0.6rem; background: #fff3d6; border-left: 3px solid var(--accent); }

.menu {
  position: fixed;
  z-index: 20;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 20px #0005;
  padding: 0.3rem;
  display: flex;
  flex-direction: column;
  min-width: 170px;
}
.menu button { border: none; text-align: left; border-radius: 5px; }
.menu .menu-title { font-size: 0.75rem; color: var(--muted); padding: 0.2rem 0.5rem; }

dialog { border: none; border-radius: var(--radius); padding: 1.25rem; max-width: 440px; width: 92vw; box-shadow: 0 10px 40px #0008; }
dialog::backdrop { background: #0009; }
dialog h2 { margin-top: 0; }
dialog label { display: block; margin: 0.5rem 0; }
dialog input, dialog select { font: inherit; padding: 0.3rem 0.4rem; }
dialog .actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }

/* ---------- Playing cards (shared by card games) ---------- */
.cards { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: flex-start; }
.card {
  width: 74px; height: 104px; border-radius: 8px; background: #fff; border: 2px solid #2a2a2a;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.2rem;
  padding: 0.3rem; text-align: center; font-weight: 800; position: relative; user-select: none;
  box-shadow: 0 2px 4px #0003; transition: transform 0.1s ease;
}
.card .big { font-size: 1.9rem; line-height: 1; }
.card .small-text { font-size: 0.62rem; font-weight: 500; line-height: 1.15; }
.card.back { background: repeating-linear-gradient(45deg, #2c4a7a, #2c4a7a 6px, #3c5d93 6px, #3c5d93 12px); border-color: #1a2e4f; }
button.card { cursor: pointer; font: inherit; font-weight: 800; color: inherit; }
button.card:hover:not(:disabled) { transform: translateY(-4px); }
button.card.selected { transform: translateY(-10px); box-shadow: 0 0 0 3px var(--accent), 0 6px 12px #0004; }
.card.dim { opacity: 0.4; }
.card.struck::after {
  content: ''; position: absolute; inset: 45% -4px auto; height: 4px; background: var(--danger); transform: rotate(-30deg); border-radius: 2px;
}
