@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700&family=Spectral:wght@400;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --bg: #f3ead7;
  --panel: #fff7ea;
  --ink: #2b1d0e;
  --accent: #b95412;
  --accent-soft: #efd5b4;
  --shadow: rgba(42, 26, 10, 0.18);
  --font-display: "Cinzel", "Garamond", "Times New Roman", serif;
  --font-body: "Spectral", "Georgia", serif;
  --font-mono: "IBM Plex Mono", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top, #fff7ea 0%, #f1e1c9 45%, #e3c6a4 100%),
    repeating-linear-gradient(120deg, rgba(255, 255, 255, 0.05) 0 10px, rgba(0, 0, 0, 0.02) 10px 20px);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100vh;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(185, 84, 18, 0.12), transparent 45%),
    radial-gradient(circle at 80% 10%, rgba(90, 55, 20, 0.12), transparent 50%),
    radial-gradient(circle at 70% 80%, rgba(185, 120, 70, 0.1), transparent 55%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.02) 0 16px, rgba(0, 0, 0, 0.02) 16px 32px),
    radial-gradient(circle at center, transparent 45%, rgba(40, 24, 10, 0.08) 46%, rgba(40, 24, 10, 0.08) 47%, transparent 48%);
  opacity: 0.6;
  pointer-events: none;
  z-index: 0;
}

#app {
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 20px 40px;
  position: relative;
  z-index: 1;
}

header {
  text-align: center;
  margin-bottom: 24px;
}

header h1 {
  font-family: var(--font-display);
  font-size: 2.6rem;
  letter-spacing: 1px;
  margin: 0 0 8px;
}

header p {
  margin: 0;
  color: #5a3a1a;
}

.panel {
  background: var(--panel);
  border: 1px solid #e7caa6;
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 12px 30px var(--shadow);
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
}

.hidden {
  display: none;
}

#auth {
  padding: 26px;
}

.auth-hero {
  display: grid;
  grid-template-columns: minmax(240px, 1.1fr) minmax(260px, 1fr);
  gap: 18px;
  align-items: stretch;
}

.auth-copy {
  padding: 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255, 248, 237, 0.9), rgba(244, 226, 198, 0.9));
  border: 1px solid #e7caa6;
  box-shadow: inset 0 0 0 1px rgba(255, 224, 190, 0.45);
}

.auth-copy h2 {
  margin: 12px 0 8px;
  font-family: var(--font-display);
  font-size: 1.8rem;
}

.auth-copy p {
  margin: 0 0 16px;
  color: #563720;
}

.auth-ornament {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #c78b51, transparent);
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(185, 84, 18, 0.18);
  color: #6a3a1a;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-cards {
  display: grid;
  gap: 12px;
}

.auth-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border-radius: 14px;
  background: #fffdf7;
  border: 1px solid #f0dcc2;
  box-shadow: inset 0 0 0 1px rgba(255, 224, 190, 0.35);
}

.auth-card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
}

input, select {
  font-family: inherit;
  font-size: 1rem;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #d9b894;
  background: #fffaf1;
}

button {
  font-family: inherit;
  font-size: 1rem;
  padding: 10px 16px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fffaf1;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(214, 109, 26, 0.3);
}

button:hover {
  filter: brightness(1.05);
}

.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.85;
}

.btn-loading::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border-radius: 50%;
  border: 2px solid rgba(255, 245, 230, 0.5);
  border-top-color: #fff5e6;
  animation: spin 0.8s linear infinite;
}

.shake {
  animation: shake 0.45s ease;
}

@keyframes spin {
  from { transform: translateY(-50%) rotate(0deg); }
  to { transform: translateY(-50%) rotate(360deg); }
}

@keyframes shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
  100% { transform: translateX(0); }
}

.msg {
  margin-top: 12px;
  color: #8d3f12;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #2d1a0f;
  color: #f7e6d3;
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: 0 10px 26px rgba(18, 10, 4, 0.45);
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 5;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

#character-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.char-card {
  padding: 12px 14px;
  border-radius: 12px;
  background: #fffdf7;
  border: 1px solid #f0dcc2;
  min-width: 180px;
}

.divider {
  margin: 18px 0;
  height: 1px;
  background: #e7caa6;
}

.game-grid {
  display: grid;
  grid-template-columns: 2.2fr 1fr;
  gap: 18px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.status-card {
  background: #fffdf7;
  border-radius: 14px;
  border: 1px solid #f0dcc2;
  padding: 14px;
  box-shadow: inset 0 0 0 1px rgba(255, 224, 190, 0.35);
}

.status-title {
  font-family: var(--font-display);
  font-size: 1rem;
  margin-bottom: 10px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  margin: 6px 0;
}

.status-row strong {
  font-weight: 600;
}

.bar-label {
  font-size: 0.9rem;
  color: #6b4a2a;
  margin: 6px 0 4px;
}

.bar {
  height: 10px;
  background: #e8d4b9;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(66, 44, 20, 0.1);
}

.bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.bar-fill.hp { background: linear-gradient(90deg, #8b1f1f, #d05a2f); }
.bar-fill.mp { background: linear-gradient(90deg, #1b4d8b, #2e8bd0); }
.bar-fill.exp { background: linear-gradient(90deg, #1f6b3b, #35b36c); }

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

.quick-btn {
  background: #f0c79e;
  color: #3b2412;
  box-shadow: inset 0 0 0 1px rgba(118, 70, 22, 0.25);
  padding: 8px 10px;
}

.log-wrap {
  display: flex;
  flex-direction: column;
  background: #1a120b;
  border-radius: 16px;
  box-shadow: inset 0 0 0 1px rgba(255, 210, 150, 0.2), 0 10px 20px rgba(13, 10, 6, 0.45);
  overflow: hidden;
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: linear-gradient(90deg, #2c1a0f 0%, #1b1008 100%);
  color: #f7e9d6;
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.5px;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(217, 108, 26, 0.25);
  color: #f5d7b8;
  font-size: 0.75rem;
}

.log {
  background: #0d0b08;
  color: #f7f1e5;
  padding: 16px;
  min-height: 360px;
  max-height: 420px;
  overflow-y: auto;
  font-family: var(--font-mono);
}

.log p {
  margin: 0 0 8px;
  white-space: pre-wrap;
}

.side {
  background: #fffdf7;
  border-radius: 14px;
  padding: 16px;
  border: 1px solid #f0dcc2;
  box-shadow: inset 0 0 0 1px rgba(255, 224, 190, 0.4);
}

.action-group {
  margin-bottom: 14px;
}

.action-title {
  font-weight: 600;
  margin-bottom: 6px;
}

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

.chip {
  border-radius: 999px;
  border: 1px solid rgba(118, 70, 22, 0.25);
  background: #f7e2c6;
  padding: 6px 10px;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: center;
}

.chip.active {
  background: #c56b2a;
  color: #fff7ea;
  border-color: #b35a1a;
}

.chip.small {
  font-size: 0.75rem;
  padding: 4px 8px;
}

.target-label {
  margin-bottom: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  background: #fff4e2;
  border: 1px solid #ead0ad;
  font-size: 0.85rem;
}

.side h3 {
  margin-top: 0;
  font-family: var(--font-display);
}

.input-row {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  align-items: center;
}

#cmd-input {
  flex: 1;
  font-family: var(--font-mono);
  background: #fffdf7;
}

ul {
  padding-left: 18px;
  margin: 8px 0;
}

li {
  margin-bottom: 6px;
}

@media (max-width: 820px) {
  .auth-hero {
    grid-template-columns: 1fr;
  }
  .status-grid {
    grid-template-columns: 1fr;
  }
  .game-grid {
    grid-template-columns: 1fr;
  }
  header h1 {
    font-size: 2.1rem;
  }
  .log {
    min-height: 300px;
  }
}
