:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --muted: #475569;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: min(1040px, 92%);
  margin: 0 auto;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
}

.brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
}

.tagline {
  font-size: 0.8rem;
  color: var(--muted);
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nav-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.nav-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

main {
  flex: 1;
  padding: 20px 0 36px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ad-container {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 8px 12px 12px;
  text-align: center;
}

.ad-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 4px;
}

.ad-placeholder {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tool-card {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.tool-card.active {
  display: block;
}

.tool-card h2 {
  font-size: 1.35rem;
  margin-bottom: 4px;
}

.subtitle {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

input[type="color"] {
  height: 42px;
  padding: 4px;
  cursor: pointer;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(37, 99, 235, 0.25);
  border-color: var(--primary);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.btn {
  border: none;
  padding: 10px 16px;
  border-radius: 9px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover {
  background: var(--primary-hover);
}

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

.btn.secondary:hover {
  background: #e2e8f0;
}

.qr-output-wrap {
  display: flex;
  justify-content: center;
  padding: 18px;
  background: var(--surface-2);
  border-radius: 12px;
}

#qr-output {
  background: #fff;
  padding: 14px;
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.stat-tile {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.stat-tile .stat-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.stat-tile .stat-val {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.split-tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 18px;
}

.sub-panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.sub-panel h3 {
  font-size: 1.05rem;
  margin-bottom: 12px;
}

.result-box {
  margin-top: 12px;
  padding: 12px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.92rem;
}

.game-box {
  height: 210px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  user-select: none;
  margin-bottom: 16px;
  transition: transform 0.08s ease;
}

.game-box:active {
  transform: scale(0.99);
}

.game-box.state-idle {
  background: #2563eb;
}

.game-box.state-waiting {
  background: #dc2626;
}

.game-box.state-ready {
  background: #16a34a;
}

.info-section h2 {
  font-size: 1.2rem;
  margin-bottom: 12px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.info-card h3 {
  font-size: 1rem;
  margin-bottom: 6px;
}

.info-card p {
  font-size: 0.88rem;
  color: var(--muted);
}

.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
}

.footer-links {
  display: flex;
  gap: 14px;
}

.footer-links a {
  color: var(--primary);
  text-decoration: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-dialog {
  background: #fff;
  width: min(560px, 100%);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
}

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

.modal-close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
}

.modal-body {
  font-size: 0.92rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
