@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=Literata:opsz,wght@7..72,500&display=swap");

:root {
  --bg-0: #151a22;
  --bg-1: #10151c;
  --card: #1d2530;
  --surface-1: #141b23;
  --surface-2: #202a36;
  --ink-1: #edf3f8;
  --ink-2: #aab6c3;
  --line: #3a4756;
  --accent: #2f9d92;
  --accent-strong: #257b72;
  --accent-soft: rgba(47, 157, 146, 0.16);
  --switch-off: #334152;
  --switch-on: #224c4a;
  --chip-bg: #15333a;
  --chip-border: #2e7f89;
  --shadow: 0 18px 36px rgba(3, 7, 12, 0.34);
  --error: #ff8d83;
  --ok: #7fd89d;
}

body[data-theme="light"] {
  --bg-0: #f6f2ea;
  --bg-1: #efe6d8;
  --card: #fffdf8;
  --surface-1: #fff;
  --surface-2: #fffaf2;
  --ink-1: #1f2421;
  --ink-2: #4b554f;
  --line: #d4c4ad;
  --accent: #0f766e;
  --accent-strong: #0d5f58;
  --accent-soft: rgba(15, 118, 110, 0.08);
  --switch-off: #efe6d8;
  --switch-on: #d9efe9;
  --chip-bg: #e8f5f2;
  --chip-border: #9bc9c4;
  --shadow: 0 8px 20px rgba(41, 29, 16, 0.08);
  --error: #b3261e;
  --ok: #176b37;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink-1);
  background:
    radial-gradient(circle at 10% 10%, rgba(39, 88, 98, 0.24) 0%, transparent 45%),
    radial-gradient(circle at 90% 90%, rgba(62, 120, 102, 0.2) 0%, transparent 38%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1));
  min-height: 100vh;
}

body[data-theme="game"] {
  background:
    linear-gradient(rgba(7, 11, 16, 0.7), rgba(7, 11, 16, 0.82)),
    radial-gradient(circle at 50% 18%, rgba(196, 156, 86, 0.2), transparent 30%),
    url("./assets/game-view-z27.png") center top / cover fixed no-repeat,
    linear-gradient(180deg, #0f1218, #11161d);
}

body[data-theme="game"] .auth-gate {
  background:
    linear-gradient(rgba(7, 11, 16, 0.24), rgba(7, 11, 16, 0.42)),
    radial-gradient(circle at 50% 14%, rgba(226, 190, 119, 0.18), transparent 26%);
}

body[data-theme="game"] .app-shell {
  position: relative;
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: min(420px, 92vw);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}

body[data-theme="game"] .auth-card,
body[data-theme="game"] .panel {
  border-color: rgba(177, 144, 88, 0.72);
  background:
    radial-gradient(circle at top, rgba(134, 102, 55, 0.16), transparent 46%),
    linear-gradient(rgba(19, 21, 29, 0.88), rgba(16, 18, 26, 0.92));
  box-shadow:
    0 22px 40px rgba(0, 0, 0, 0.44),
    inset 0 1px 0 rgba(241, 216, 166, 0.08),
    0 0 0 1px rgba(86, 66, 35, 0.44);
  backdrop-filter: blur(4px);
}

body[data-theme="game"] .auth-card {
  border-radius: 12px;
  background:
    linear-gradient(rgba(9, 12, 18, 0.72), rgba(9, 12, 18, 0.84)),
    linear-gradient(135deg, rgba(120, 88, 43, 0.18), transparent 42%),
    radial-gradient(circle at top, rgba(222, 183, 104, 0.2), transparent 38%);
}

body[data-theme="game"] .auth-card-topbar,
body[data-theme="game"] .hero-actions {
  padding-bottom: 6px;
}

body[data-theme="game"] .hero {
  padding-top: 18px;
}

body[data-theme="game"] .hero-title-wrap,
body[data-theme="game"] .panel,
body[data-theme="game"] .auth-card {
  position: relative;
}

body[data-theme="game"] .panel::before,
body[data-theme="game"] .auth-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(186, 154, 95, 0.18);
  border-radius: 10px;
  pointer-events: none;
}

body[data-theme="game"] .auth-card h1,
body[data-theme="game"] .hero h1 {
  color: #f0e2bf;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.5);
}

body[data-theme="game"] .auth-card p,
body[data-theme="game"] .hero p,
body[data-theme="game"] .hint {
  color: #d2c5aa;
}

body[data-theme="game"] .session-mode-banner,
body[data-theme="game"] .stat-chip {
  border-color: rgba(181, 149, 88, 0.72);
  background: rgba(73, 52, 23, 0.62);
}

body[data-theme="game"] input,
body[data-theme="game"] select {
  border-color: rgba(153, 129, 82, 0.58);
  background: rgba(15, 19, 26, 0.82);
  color: #f0e2bf;
}

body[data-theme="game"] button {
  background: linear-gradient(180deg, #90724a, #65492a);
  color: #f8ecd0;
}

body[data-theme="game"] button:hover {
  background: linear-gradient(180deg, #a78455, #745536);
}

body[data-theme="game"] .auth-action-btn-secondary,
body[data-theme="game"] .admin-inline-btn,
body[data-theme="game"] .admin-close-btn,
body[data-theme="game"] .filter-toggle-btn,
body[data-theme="game"] .stat-mode-btn,
body[data-theme="game"] .stat-add-btn,
body[data-theme="game"] .clear-search-btn {
  background: rgba(39, 29, 18, 0.84);
  color: #f4e8cd;
  border-color: rgba(181, 149, 88, 0.58);
}

body[data-theme="game"] .stat-mode-btn.is-active {
  background: linear-gradient(180deg, #90724a, #65492a);
  border-color: rgba(201, 171, 108, 0.7);
}

body[data-theme="game"] .search-results {
  border-top-color: rgba(181, 149, 88, 0.28);
}

body[data-theme="game"] .search-item {
  border-bottom-color: rgba(181, 149, 88, 0.22);
  background: rgba(17, 21, 28, 0.28);
}

body[data-theme="game"] .search-item:hover {
  background: rgba(96, 74, 39, 0.42);
}

body[data-theme="game"] .search-item strong {
  color: #f3ead6;
}

body[data-theme="game"] .search-item-meta {
  color: #d0c0a2;
}

body[data-theme="game"] .search-item img {
  background: rgba(11, 14, 20, 0.75);
  border-color: rgba(181, 149, 88, 0.34);
}

body[data-theme="game"] .theme-select-wrap label,
body[data-theme="game"] label {
  color: #f0e2bf;
}

.auth-card-topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.auth-card label {
  margin-top: 12px;
}

.auth-card input {
  margin-bottom: 4px;
}

.auth-card h1 {
  margin: 0 0 6px;
  font-family: "Literata", serif;
  font-size: 1.8rem;
}

.auth-card p {
  margin: 0 0 14px;
  color: var(--ink-2);
}

.auth-session-info {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink-1);
  font-size: 0.95rem;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
  margin-bottom: 10px;
}

.auth-action-btn {
  width: 100%;
  margin-top: 0;
}

.auth-action-btn-secondary {
  background: var(--surface-2);
  color: var(--ink-1);
  border: 1px solid var(--line);
}

.auth-action-btn-secondary:hover {
  background: var(--accent-soft);
  color: var(--ink-1);
}

.auth-demo-btn {
  margin-top: 4px;
}

#authPendingActions {
  margin-top: 8px;
}

.app-shell {
  width: min(680px, 94vw);
  margin: 16px auto 28px;
}

.hero {
  padding: 12px 4px;
}

.hero-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.hero-title-wrap {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.hero-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.hero h1 {
  margin: 0;
  font-family: "Literata", serif;
  font-size: clamp(1.7rem, 4vw, 2.2rem);
}

.hero p {
  margin: 4px 0 0;
  color: var(--ink-2);
}

.session-mode-banner {
  margin-top: 8px;
  display: inline-block;
  padding: 6px 10px;
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--ink-1);
  font-size: 0.8rem;
  font-weight: 600;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px;
}

label {
  display: block;
  font-weight: 700;
  font-size: 0.92rem;
  margin: 8px 2px 6px;
}

input,
select,
button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  font: inherit;
}

input,
select {
  padding: 11px 12px;
  background: var(--surface-1);
  color: var(--ink-1);
}

input:focus,
select:focus {
  outline: 2px solid #8bc9c3;
  outline-offset: 1px;
}

.hint {
  margin: 8px 0 8px;
  font-size: 0.87rem;
  color: var(--ink-2);
}

.comment-count {
  margin-top: 4px;
  text-align: right;
}

.search-input-wrap {
  position: relative;
}

.search-input-wrap input {
  padding-right: 44px;
}

.clear-search-btn {
  position: absolute;
  top: 50%;
  right: 8px;
  width: 28px;
  height: 28px;
  margin-top: 0;
  transform: translateY(-50%);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
}

.clear-search-btn:hover {
  background: var(--accent-soft);
  color: var(--ink-1);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.filter-toggle-btn {
  width: auto;
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--ink-1);
}

.filter-panel {
  overflow: hidden;
}

.filter-grid-wide {
  grid-column: 1 / -1;
}

.toggle-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toggle-field label:first-child {
  margin-bottom: 0;
}

.theme-select-wrap {
  min-width: 148px;
  flex-shrink: 0;
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 52px;
  height: 32px;
  margin-top: 8px;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-slider {
  position: relative;
  width: 52px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--switch-off);
  transition: background 140ms ease, border-color 140ms ease;
}

.switch-slider::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-1);
  box-shadow: 0 1px 3px rgba(31, 36, 33, 0.18);
  transition: transform 140ms ease;
}

.switch input:checked + .switch-slider {
  background: var(--switch-on);
  border-color: var(--accent);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}

.filter-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.filter-label-row label {
  margin-bottom: 0;
}

.stat-mode-toggle {
  display: inline-flex;
  gap: 6px;
}

.stat-mode-btn,
.stat-add-btn {
  width: auto;
  margin-top: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--ink-1);
  font-size: 0.85rem;
  font-weight: 600;
}

.stat-mode-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.stat-picker-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.stat-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 38px;
  margin: 8px 0 10px;
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.stat-chip {
  width: auto;
  margin-top: 0;
  padding: 7px 12px;
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--ink-1);
  font-size: 0.84rem;
  font-weight: 600;
}

.stat-chip::after {
  content: " x";
}

.stat-chip-empty {
  align-self: center;
  color: var(--ink-2);
  font-size: 0.85rem;
}

.search-results {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  border-top: 1px dashed var(--line);
}

.search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink-1);
  text-align: left;
  padding: 10px 2px;
  cursor: pointer;
}

.search-item:hover {
  background: var(--accent-soft);
}

.search-item img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.search-item strong {
  font-size: 0.96rem;
  color: var(--ink-1);
}

.search-item-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.search-item-meta {
  color: var(--ink-2);
  font-size: 0.82rem;
}

.item-editor {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.hidden {
  display: none;
}

.item-header {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 10px;
  align-items: center;
}

.item-header img {
  width: 60px;
  height: 60px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.item-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.last-entry {
  margin: 3px 0 0;
  color: var(--ink-2);
  font-size: 0.88rem;
}

.field-grid {
  margin-top: 10px;
}

button {
  margin-top: 12px;
  padding: 12px 14px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

.status-message {
  min-height: 22px;
  margin: 10px 2px 0;
  font-weight: 500;
}

.status-message.ok {
  color: var(--ok);
}

.status-message.error {
  color: var(--error);
}

.admin-panel {
  margin-top: 14px;
}

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.admin-nav-btn,
.admin-sort-btn {
  width: auto;
  margin-top: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--ink-1);
}

.admin-nav-btn.is-active,
.admin-sort-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.admin-panel-header,
.admin-card-header,
.admin-form-actions,
.admin-actions-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.admin-panel-header h2,
.admin-card-header h3 {
  margin: 0;
}

.admin-card {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.admin-user-form {
  margin-top: 8px;
}

.admin-approval-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-form-actions {
  justify-content: flex-start;
  margin-top: 10px;
}

.admin-inline-btn,
.admin-close-btn {
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-1);
  color: var(--ink-1);
  white-space: nowrap;
}

.admin-inline-btn-danger {
  background: rgba(179, 38, 30, 0.14);
  color: var(--error);
}

.admin-inline-btn-secondary {
  background: var(--surface-2);
}

.hidden,
.admin-inline-btn.hidden,
.admin-close-btn.hidden {
  display: none !important;
}

.admin-table-wrap {
  overflow-x: auto;
  margin-top: 10px;
}

.admin-table-wrap-scroll {
  max-height: 520px;
  overflow-y: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.admin-table th,
.admin-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  font-size: 0.82rem;
  color: var(--ink-2);
}

.admin-sort-btn {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
  font-weight: 700;
}

.admin-sort-btn.is-active {
  background: transparent;
  border-color: transparent;
  color: var(--ink-1);
}

.admin-table td input,
.admin-table td select {
  min-width: 92px;
}

@media (min-width: 720px) {
  .panel {
    padding: 18px;
  }
}

@media (max-width: 560px) {
  .hero-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-title-wrap {
    justify-content: flex-start;
  }

  .hero-actions {
    justify-content: space-between;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  .filter-label-row {
    flex-direction: column;
    align-items: stretch;
  }

  .stat-picker-row {
    grid-template-columns: 1fr;
  }
}
