/* Copyright (c) 2016,2026 Oliver Merkel. All rights reserved. MIT License */

/* Guard the HTML [hidden] attribute against accidental CSS override.
   Required when any CSS rule sets display on the same elements. */
[hidden] { display: none !important; }

/* =========================================================================
   CSS custom properties (design tokens)
   ========================================================================= */

:root {
  --color-bg:       #1a1a2e;
  --color-surface:  #16213e;
  --color-border:   #0f3460;
  --color-accent:   #e94560;
  --color-text:     #e0e0e0;
  --color-text-dim: #888;
  --color-gold:     #ffcc00;

  --header-h:       52px;
  --panel-w:        260px;
  --radius:         8px;
  --transition:     0.25s ease;

  --font-ui: system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
}

/* =========================================================================
   Reset / base
   ========================================================================= */

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

html, body {
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-ui);
  font-size: 16px;
  overflow: hidden;
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

ul { list-style: none; }

/* =========================================================================
   Layout shell
   ========================================================================= */

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;        /* dynamic viewport height */
}

/* ---- header ---- */

#app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--header-h);
  padding: 0 12px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  z-index: 10;
  flex-shrink: 0;
}

#app-header-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex: 1;
  text-align: center;
  color: var(--color-gold);
}

#app-header-badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text);
  background: var(--color-border);
  border: 1px solid #1b4d85;
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

/* ---- main content area ---- */

#app-content {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

/* =========================================================================
   Views (game / rules / options / about)
   ========================================================================= */

.view {
  padding: 12px 16px;
  max-width: 780px;
  margin: 0 auto;
}

/* game view uses all available height */
#view-game {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 0;
}

/* =========================================================================
   Board container
   ========================================================================= */

#board {
  width: 100%;
  max-width: min(calc(100vw - 12px), calc((100dvh - var(--header-h)) * 1950 / 1450));
  aspect-ratio: 1950 / 1450;
  overflow: hidden;
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,0,0,.6);
}

#board svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* =========================================================================
   Side panel
   ========================================================================= */

#panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 40;
}

#side-panel {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--panel-w);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  z-index: 50;
  transform: translateX(calc(0px - var(--panel-w)));
  transition: transform var(--transition);
  display: flex;
  flex-direction: column;
  padding: 16px 0;
}

#side-panel.open { transform: translateX(0); }

.panel-title {
  font-size: 1rem;
  font-weight: 600;
  padding: 0 20px 12px;
  color: var(--color-text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel-nav li a,
.panel-nav li button {
  display: block;
  width: 100%;
  padding: 12px 20px;
  background: none;
  border: none;
  text-align: left;
  color: var(--color-text);
  font-size: 1rem;
  cursor: pointer;
  transition: background var(--transition);
}

.panel-nav li a:hover,
.panel-nav li button:hover {
  background: var(--color-border);
  text-decoration: none;
}

.panel-divider {
  height: 1px;
  background: var(--color-border);
  margin: 8px 0;
}

/* =========================================================================
   Icon buttons (hamburger, back)
   ========================================================================= */

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background var(--transition);
}

.icon-btn:hover { background: var(--color-border); }

.icon-btn img,
.icon-btn svg {
  width: 24px;
  height: 24px;
  filter: invert(1);
}

/* =========================================================================
   Content sections (rules / options / about)
   ========================================================================= */

.view-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.view-section h2 {
  font-size: 1.3rem;
  color: var(--color-gold);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 6px;
}

.view-section h3 {
  font-size: 1.1rem;
  color: var(--color-text);
  margin-top: 8px;
}

.view-section h4 {
  font-size: 1rem;
  color: var(--color-accent);
}

.view-section p, .view-section li { line-height: 1.6; }

.view-section ol, .view-section ul { padding-left: 1.4em; }

/* Collapsible rules sections */
.view-section details {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.view-section details summary {
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.view-section details summary::after {
  content: '›';
  font-size: 1.2rem;
  transition: transform var(--transition);
}

.view-section details[open] summary::after { transform: rotate(90deg); }

.view-section details > div {
  padding: 12px 14px;
  border-top: 1px solid var(--color-border);
}

/* Diagram figures */
figure.diagram {
  display: inline-block;
  max-width: 360px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 8px 0;
  vertical-align: top;
}

figure.diagram img,
figure.diagram embed {
  width: 100%;
  display: block;
}

figure.diagram figcaption {
  background: var(--color-border);
  color: var(--color-text-dim);
  font-style: italic;
  font-size: 0.85rem;
  padding: 6px 10px;
}

/* =========================================================================
   Options form
   ========================================================================= */

.options-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.options-form fieldset {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.options-form legend {
  padding: 0 8px;
  font-weight: 600;
  color: var(--color-text-dim);
}

.options-form label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  cursor: pointer;
}

.options-form input[type="radio"],
.options-form input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-accent);
  cursor: pointer;
}

.hint-text {
  font-size: 0.85rem;
  color: var(--color-text-dim);
  font-style: italic;
}

/* =========================================================================
   Buttons
   ========================================================================= */

.btn {
  display: inline-block;
  padding: 10px 22px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  cursor: pointer;
  transition: opacity var(--transition);
  text-align: center;
}

.btn:hover { opacity: 0.85; text-decoration: none; color: #fff; }

.btn-secondary {
  background: var(--color-border);
  color: var(--color-text);
}

.btn-back {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

/* =========================================================================
   Responsive adjustments
   ========================================================================= */

@media (max-width: 480px) {
  #app-header-title { font-size: 1rem; }
  #app-header-badge { font-size: 0.65rem; padding: 3px 8px; }
  .view { padding: 8px 10px; }
}
