/* © 2026 pluvius.dev. All rights reserved. */
/* Shared theme & app-shell primitives for all PuzzleSuite games. */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #1c2333;
  --text-dim: #6b7280;
  --border: #d8dee9;
  --cell-given: #1c2333;
  --cell-user: #3461eb;
  --cell-selected: #cfe0ff;
  --cell-peer: #e8edf9;
  --cell-same: #d3e0fc;
  --cell-conflict: #ffd7d7;
  --cell-conflict-text: #d92626;
  --accent: #4f7cff;
  --accent-text: #ffffff;
  --box-border: #33415c;
  --shadow: 0 2px 10px rgba(20, 30, 60, 0.08);
  --region-0: #eca5a2;
  --region-1: #e4ad84;
  --region-2: #ccba7b;
  --region-3: #91cba0;
  --region-4: #8ac2ed;
  --region-5: #b5b3ef;
  --region-6: #cfabe1;
  --region-7: #f2c791;
  --region-8: #93d6d6;
  --region-9: #e8a0c8;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #12151f;
  --surface: #1b202e;
  --text: #e7ebf5;
  --text-dim: #9aa4b8;
  --border: #2c3346;
  --cell-given: #e7ebf5;
  --cell-user: #7fa2ff;
  --cell-selected: #2c3f6e;
  --cell-peer: #232a3d;
  --cell-same: #2d3f66;
  --cell-conflict: #4a2130;
  --cell-conflict-text: #ff8080;
  --accent: #5b86ff;
  --accent-text: #ffffff;
  --box-border: #aab6d4;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  --region-0: #6b3030;
  --region-1: #66380c;
  --region-2: #544400;
  --region-3: #18522e;
  --region-4: #0e496e;
  --region-5: #413d70;
  --region-6: #563664;
  --region-7: #66491a;
  --region-8: #1a5656;
  --region-9: #662548;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151f;
    --surface: #1b202e;
    --text: #e7ebf5;
    --text-dim: #9aa4b8;
    --border: #2c3346;
    --cell-given: #e7ebf5;
    --cell-user: #7fa2ff;
    --cell-selected: #2c3f6e;
    --cell-peer: #232a3d;
    --cell-same: #2d3f66;
    --cell-conflict: #4a2130;
    --cell-conflict-text: #ff8080;
    --accent: #5b86ff;
    --accent-text: #ffffff;
    --box-border: #aab6d4;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
    --region-0: #6b3030;
    --region-1: #66380c;
    --region-2: #544400;
    --region-3: #18522e;
    --region-4: #0e496e;
    --region-5: #413d70;
    --region-6: #563664;
    --region-7: #66491a;
    --region-8: #1a5656;
    --region-9: #662548;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 8px;
}

.logo {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

.logo-link {
  text-decoration: none;
  color: inherit;
}

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.primary-btn,
.secondary-btn {
  flex: 1;
  width: 100%;
  box-sizing: border-box;
  border-radius: 12px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s, background-color 0.15s, transform 0.1s;
}

.primary-btn {
  background: var(--accent);
  color: #ffffff;
  border: none;
}

.primary-btn:hover {
  opacity: 0.92;
}

.primary-btn:active {
  transform: scale(0.98);
}

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

.secondary-btn:hover {
  opacity: 0.88;
}

.secondary-btn:active {
  transform: scale(0.98);
}

.text-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  padding: 8px;
  margin-top: 8px;
  cursor: pointer;
  width: 100%;
}

.ctrl-btn:disabled,
.ctrl-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.text-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 12px;
  font-family: inherit;
}

.foot {
  text-align: center;
  padding-top: 10px;
  font-size: 12px;
  color: var(--text-dim);
  min-height: 18px;
}

.foot .credit {
  margin-top: 2px;
}

.brand-line {
  color: var(--text-dim);
  font-size: 12px;
  margin: -4px 0 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 24, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal.hidden { display: none; }

.modal-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 24px 20px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: var(--shadow);
}

.modal-card h2 { margin: 0 0 6px; }
.modal-sub { color: var(--text-dim); font-size: 13px; margin: 0 0 16px; }

@media (min-width: 500px) {
  .app { padding-top: 24px; }
}

.lang-select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: background 0.2s, border-color 0.2s;
}

.lang-select:hover, .lang-select:focus {
  border-color: var(--accent);
}

.modal-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 8px 0 18px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.2);
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions .primary-btn,
.modal-actions .secondary-btn {
  flex: 1;
}
