/* ── Netwalk — style.css ──────────────────────── */
/* No frameworks. No resets from npm. Just what we need. */

:root {
  /* Background */
  --color-bg: #0d0d1a;
  --color-surface-bg: #1a1a2e;
  --color-hover-bg: #16213e;
  --color-grid-line: rgba(255,255,255,0.03);

  /* Text */
  --color-text: #e2e8f0;
  --color-text-secondary: #cbd5e1;
  --color-text-muted: #94a3b8;
  --color-text-dim: #64748b;
  --color-text-subtle: #475569;

  /* Accent */
  --color-accent: #00b8d4;
  --color-accent-bright: #00e5ff;
  --color-accent-bg: rgba(0,184,212,0.08);

  /* Server */
  --color-server: #f09837;
  --color-server-hover: #f0a855;
  --color-server-bg: rgba(240,152,55,0.08);
  --color-server-bg-strong: rgba(240,152,55,0.15);

  /* Borders */
  --color-border: #1e293b;
  --color-border-light: #334155;

  /* Canvas (JS also reads these) */
  --color-bg-alt: #1b1b2f;
  --color-surface: #16213e;
  --color-border-canvas: #0f3460;
  --color-pipe-off: #2d3a52;
  --color-pipe-glow: rgba(0,229,255,0.35);
  --color-server-glow: rgba(240,152,55,0.5);
  --color-locked: rgba(255,255,255,0.12);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans SC", "Noto Sans JP", "Noto Sans KR", "Microsoft YaHei", sans-serif;
  background: var(--color-bg);
  color: var(--color-text-secondary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(0,184,212,0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(240,152,55,0.03) 0%, transparent 50%),
    linear-gradient(var(--color-grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--color-grid-line) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 32px 32px, 32px 32px;
}

/* ── Layout ──────────────────────────────────── */
.site-header {
  width: 100%;
  max-width: 720px;
  padding: 24px 20px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

.site-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: 0.02em;
}
.site-title span {
  color: var(--color-accent);
  font-weight: 400;
}

.lang-switch {
  font-size: 0.78rem;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.lang-switch a {
  color: var(--color-text-dim);
  text-decoration: none;
  padding: 3px 8px;
  border: 1px solid var(--color-border);
  transition: all 0.15s;
  white-space: nowrap;
}
.lang-switch a:hover,
.lang-switch a.active {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

main {
  width: 100%;
  max-width: 720px;
  padding: 16px 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Controls bar ────────────────────────────── */
.controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

/* Size row: presets + custom */
.size-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.size-presets {
  display: flex;
  gap: 0;
  border: 1px solid var(--color-border);
}
.size-btn {
  background: transparent;
  color: var(--color-text-dim);
  border: none;
  padding: 5px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.size-btn + .size-btn { border-left: 1px solid var(--color-border); }
.size-btn:hover { color: var(--color-text-muted); background: var(--color-hover-bg); }
.size-btn.active {
  color: var(--color-accent);
  background: var(--color-accent-bg);
}

#daily-btn {
  background: transparent;
  color: var(--color-server);
  border: none;
  padding: 5px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  border-left: 1px solid var(--color-border);
}
#daily-btn:hover { color: var(--color-server-hover); background: var(--color-server-bg); }
#daily-btn.active {
  color: var(--color-server);
  background: var(--color-server-bg-strong);
}

/* Custom size form */
.custom-size {
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--color-border);
  padding: 0 6px;
}
.custom-size input[type="number"] {
  background: transparent;
  color: var(--color-text);
  border: none;
  width: 38px;
  text-align: center;
  font-size: 0.8rem;
  font-family: "JetBrains Mono","SF Mono","Cascadia Code","Consolas",monospace;
  padding: 5px 0;
  -moz-appearance: textfield;
}
.custom-size input[type="number"]::-webkit-inner-spin-button,
.custom-size input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.custom-size input[type="number"]:focus {
  outline: none;
  color: var(--color-accent-bright);
}
.custom-x {
  color: var(--color-text-subtle);
  font-size: 0.85rem;
}
.custom-size button {
  background: transparent;
  color: var(--color-accent);
  border: none;
  padding: 5px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: all 0.15s;
}
.custom-size button:hover {
  color: var(--color-accent-bright);
}

/* Action row: undo + new game + stats */
.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

#undo-btn {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border-light);
  padding: 5px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
#undo-btn:hover:not(:disabled) {
  color: var(--color-text);
  border-color: var(--color-text-dim);
  background: var(--color-hover-bg);
}
#undo-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.stats {
  display: flex;
  gap: 16px;
  font-size: 0.85rem;
  margin-left: auto;
}
.stat-label { color: var(--color-text-dim); margin-right: 4px; }
.stat-value {
  color: var(--color-text);
  font-family: "JetBrains Mono","SF Mono","Cascadia Code","Consolas",monospace;
}
#best { color: var(--color-server); }

#new-game-btn {
  background: transparent;
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
  padding: 5px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
#new-game-btn:hover {
  background: var(--color-accent-bg);
}

/* Locked hint */
.locked-hint {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.locked-hint.show {
  opacity: 0.8;
}

/* Toast */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--color-border);
  color: var(--color-text);
  padding: 8px 20px;
  font-size: 0.85rem;
  font-family: inherit;
  border: 1px solid var(--color-border-light);
  opacity: 0;
  transition: all 0.25s;
  pointer-events: none;
  z-index: 100;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Canvas ──────────────────────────────────── */
.canvas-wrap {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}
#game-canvas {
  cursor: pointer;
  display: block;
  max-width: 100%;
}
#game-canvas:active { cursor: pointer; }

/* ── Ad slots ────────────────────────────────── */
/* Ad containers: invisible when empty, hold space when filled.
   To see ad boundaries during development, uncomment the
   background rule in .ad-slot below. */
.ad-slot {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  /*  Uncomment to debug placement:
      background: rgba(255,0,0,0.1);
      outline: 1px dashed rgba(255,0,0,0.3);
      color: rgba(255,0,0,0.4);
      font-size: 0.75rem;
  */
}
.ad-slot::before {
  /* Slot label, shown only when container is empty */
  content: attr(data-ad-slot);
  display: block;
  color: var(--color-border-light);
  font-size: 0.7rem;
  font-family: "JetBrains Mono",monospace;
}
.ad-slot:not(:empty)::before {
  display: none;
}

.ad-top {
  min-height: 60px;  /* desktop banner; override to 90px for 728x90 */
  margin-bottom: 12px;
}

.ad-bottom {
  min-height: 100px; /* rectangle; override to 250px for 300x250 */
  margin-top: 20px;
  margin-bottom: 8px;
}
.win-message {
  display: none;
  text-align: center;
  margin-top: 16px;
  animation: fadeUp 0.4s ease-out;
}
.win-message h2 {
  font-size: 1.3rem;
  color: var(--color-accent-bright);
  font-weight: 600;
  margin-bottom: 4px;
}
.win-message p {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-bottom: 12px;
}
#play-again-btn {
  background: var(--color-accent);
  color: var(--color-bg);
  border: none;
  padding: 8px 24px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
#play-again-btn:hover { background: var(--color-accent-bright); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── How to play ─────────────────────────────── */
.howtoplay {
  width: 100%;
  margin-top: 32px;
  padding: 24px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-bg);
}
.howtoplay h3 {
  font-size: 1rem;
  color: var(--color-text);
  margin-bottom: 12px;
}
.howtoplay ol {
  list-style-position: inside;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}
.howtoplay li { margin-bottom: 6px; }
.howtoplay li:last-child { margin-bottom: 0; }
.howtoplay kbd {
  display: inline-block;
  padding: 1px 6px;
  font-size: 0.8rem;
  font-family: "JetBrains Mono","SF Mono",monospace;
  background: var(--color-border);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border-light);
  vertical-align: 1px;
}

/* ── Footer ──────────────────────────────────── */
.site-footer {
  width: 100%;
  max-width: 720px;
  padding: 0 20px 24px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--color-text-subtle);
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 500px) {
  .site-header { padding-top: 16px; }
  .site-title { font-size: 1.25rem; }
  .controls { gap: 6px; }
  .size-presets { flex-wrap: wrap; }
  .size-btn { padding: 4px 8px; font-size: 0.75rem; }
  .custom-size input[type="number"] { width: 32px; font-size: 0.75rem; }
  .custom-size button { padding: 4px 8px; font-size: 0.75rem; }
  .action-row { gap: 6px; }
  .stats { gap: 10px; font-size: 0.78rem; margin-left: 0; }
  #new-game-btn, #undo-btn { padding: 4px 10px; font-size: 0.78rem; }
  .howtoplay { padding: 16px; }
  .ad-top  { min-height: 50px; }
  .ad-bottom { min-height: 80px; }
}
