/*
 * LUNA — Style
 * Modernes Glass-UI über nächtlicher Jahrmarkt-Welt:
 * Tinte-Schwarz, warmes Laternen-Amber, Neon-Cyan. Handgemacht,
 * kein Framework — nur CSS.
 */

@font-face {
  font-family: 'Limelight';
  src: url('../shared/fonts/limelight-400.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('../shared/fonts/cormorant-400.woff2') format('woff2');
  font-display: swap;
}

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

:root {
  --glass: rgba(13, 15, 22, 0.66);
  --glass-border: rgba(255, 255, 255, 0.09);
  --amber: #fca04a;
  --amber-soft: rgba(252, 160, 74, 0.16);
  --cyan: #00e5ff;
  --ink: #0c0d10;
  --text: #e8dcc8;
  --text-dim: rgba(207, 196, 174, 0.85);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0c0d10;
  font-family: 'Cormorant Garamond', serif;
  color: var(--text);
}

canvas {
  display: block;
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

#game { cursor: default; }
body.building #game { cursor: crosshair; }

#hud {
  z-index: 5;
  pointer-events: none;
}

#minimap {
  position: fixed;
  left: auto;
  top: auto;
  right: 14px;
  bottom: 14px;
  width: 176px;
  height: 96px;
  z-index: 15;
  background: rgba(10, 12, 18, 0.75);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.backlink {
  position: fixed;
  top: 12px;
  left: 14px;
  z-index: 30;
  color: rgba(200, 162, 74, 0.55);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s;
}
.backlink:hover { color: rgba(200, 162, 74, 0.95); }

/* ── Toolbar (Glass-Dock, unten) ─────────────────────────────── */

#toolbar {
  position: fixed;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  gap: 4px;
  align-items: stretch;
  padding: 8px;
  max-width: min(96vw, 1500px);
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(252, 160, 74, 0.4) transparent;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  user-select: none;
}

.tool {
  position: relative;
  min-width: 56px;
  padding: 7px 6px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  border-radius: 12px;
  border: 1px solid transparent;
  color: var(--text-dim);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.tool:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.tool.active {
  background: var(--amber-soft);
  border-color: rgba(252, 160, 74, 0.55);
  color: #ffd9a0;
  box-shadow: 0 0 16px rgba(252, 160, 74, 0.25);
}

.tool .icon {
  font-size: 19px;
  line-height: 1.15;
  font-family: 'Limelight', serif;
}
.tool .label {
  font-size: 11px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.tool .price {
  font-size: 10px;
  color: rgba(200, 162, 74, 0.8);
  font-family: monospace;
}

/* Tooltip */
.tool::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(2px);
  padding: 6px 12px;
  background: rgba(8, 9, 14, 0.95);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}
.tool:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.tool-sep {
  width: 1px;
  align-self: stretch;
  background: rgba(255, 255, 255, 0.08);
  margin: 4px 3px;
}

/* ── Panel (Glass, rechts, slide-in) ────────────────────────── */

#panel {
  position: fixed;
  right: 14px;
  top: 60px;
  z-index: 20;
  width: 264px;
  display: none;
  padding: 16px 18px 14px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
}

#panel.active {
  display: block;
  animation: panel-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes panel-in {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

#panel h3 {
  font-family: 'Limelight', serif;
  font-weight: 400;
  font-size: 17px;
  letter-spacing: 0.07em;
  color: var(--cyan);
  margin-bottom: 10px;
  padding-right: 20px;
}

#panel .row {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  padding: 3px 0;
  color: var(--text-dim);
}
#panel .row b { color: #ffd9a0; font-family: monospace; font-weight: 400; }

#panel .section {
  margin: 10px 0 4px;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: rgba(200, 162, 74, 0.7);
}

/* Bedürfnis-Balken */
#panel .need {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}
#panel .need-label {
  width: 62px;
  font-size: 14px;
  color: var(--text-dim);
}
#panel .bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}
#panel .bar i {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}
#panel .bar .hunger  { background: linear-gradient(90deg, #b06a30, #f0a050); }
#panel .bar .thirst  { background: linear-gradient(90deg, #2070a0, #40b0e0); }
#panel .bar .bladder { background: linear-gradient(90deg, #3a7a4c, #60c07c); }
#panel .bar .mood    { background: linear-gradient(90deg, #b04898, #f080c8); }
#panel .bar .nausea  { background: linear-gradient(90deg, #6a7a30, #a8c050); }
#panel .need-value {
  width: 30px;
  text-align: right;
  font-family: monospace;
  font-size: 12px;
  color: var(--text-dim);
}

#panel .thought {
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-left: 2px solid rgba(0, 229, 255, 0.5);
  border-radius: 0 8px 8px 0;
  font-style: italic;
  font-size: 15px;
  color: var(--text);
}

/* Preis-Stepper */
#panel .price-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
}
#panel .price-row button {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #ffd9a0;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s;
}
#panel .price-row button:hover { background: rgba(252, 160, 74, 0.25); }
#panel .stepper-label {
  flex: 1;
  font-size: 14px;
  color: var(--text-dim);
}
#panel .value {
  font-family: monospace;
  font-size: 15px;
  color: #ffd9a0;
}

/* Toggle-Switch (öffnen/schließen) */
#panel .switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 4px;
  font-size: 14px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}
#panel .switch {
  position: relative;
  width: 46px; height: 24px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: background 0.2s;
}
#panel .switch i {
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #9aa0ac;
  transition: left 0.2s, background 0.2s;
}
#panel .switch.on {
  background: rgba(80, 220, 140, 0.3);
  border-color: rgba(80, 220, 140, 0.6);
}
#panel .switch.on i {
  left: 24px;
  background: #50dc8c;
}

#panel .close {
  position: absolute;
  top: 8px; right: 10px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.45);
  font-size: 15px;
  cursor: pointer;
}
#panel .close:hover { color: #fff; }

#panel .danger {
  margin-top: 10px;
  width: 100%;
  padding: 7px;
  border-radius: 10px;
  background: rgba(220, 60, 40, 0.12);
  border: 1px solid rgba(220, 60, 40, 0.45);
  color: #ff9a8a;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
}
#panel .danger:hover { background: rgba(220, 60, 40, 0.28); }

/* ── Screens (Titel, Game Over) ─────────────────────────────── */

#screens {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: none;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(10, 10, 18, 0.45), rgba(5, 5, 10, 0.8));
}

#screens.active { display: flex; }

.luna-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 52px 76px;
  background: rgba(10, 10, 18, 0.82);
  border: 1px solid rgba(252, 160, 74, 0.3);
  border-radius: 24px;
  box-shadow: 0 0 100px rgba(252, 160, 74, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  text-align: center;
  animation: screen-in 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

@keyframes screen-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

.luna-logo {
  font-family: 'Limelight', serif;
  font-size: 92px;
  line-height: 1;
  letter-spacing: 0.22em;
  margin-right: -0.22em;
  color: #ffd890;
  text-shadow:
    0 0 22px rgba(255, 200, 110, 0.75),
    0 0 70px rgba(255, 160, 60, 0.4);
  animation: logo-breathe 3.2s ease-in-out infinite;
}

@keyframes logo-breathe {
  0%, 100% { text-shadow: 0 0 22px rgba(255, 200, 110, 0.75), 0 0 70px rgba(255, 160, 60, 0.4); }
  50%      { text-shadow: 0 0 34px rgba(255, 200, 110, 0.95), 0 0 90px rgba(255, 160, 60, 0.55); }
}

.luna-sub {
  font-size: 15px;
  letter-spacing: 0.3em;
  margin-right: -0.3em;
  color: rgba(207, 196, 174, 0.85);
}

.luna-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  min-width: 280px;
}

.luna-buttons button {
  padding: 12px 30px;
  font-family: 'Limelight', serif;
  font-size: 15px;
  letter-spacing: 0.14em;
  color: #ffd9a0;
  background: rgba(252, 160, 74, 0.07);
  border: 1px solid rgba(252, 160, 74, 0.45);
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}

.luna-buttons button:hover:not(:disabled) {
  background: rgba(252, 160, 74, 0.2);
  box-shadow: 0 0 26px rgba(252, 160, 74, 0.3);
  transform: translateY(-1px);
}

.luna-buttons button:disabled {
  opacity: 0.35;
  cursor: default;
}

.luna-buttons button.primary {
  color: var(--ink);
  background: #fca04a;
  border-color: #fca04a;
}
.luna-buttons button.primary:hover:not(:disabled) {
  background: #ffb76b;
  box-shadow: 0 0 34px rgba(252, 160, 74, 0.55);
}

.luna-controls {
  display: grid;
  grid-template-columns: auto auto;
  gap: 5px 24px;
  margin-top: 12px;
  font-size: 14px;
  color: rgba(207, 196, 174, 0.75);
  text-align: left;
}
.luna-controls .key {
  color: var(--cyan);
  font-family: monospace;
  font-size: 13px;
}

.luna-gameover {
  font-family: 'Limelight', serif;
  font-size: 64px;
  letter-spacing: 0.16em;
  color: #ff6a5a;
  text-shadow: 0 0 34px rgba(255, 80, 60, 0.5);
}

/* ── Toast ───────────────────────────────────────────────────── */

#luna-toast {
  position: fixed;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  padding: 10px 22px;
  background: rgba(10, 12, 18, 0.92);
  border: 1px solid rgba(200, 162, 74, 0.45);
  border-radius: 999px;
  color: #ffd9a0;
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
#luna-toast.show { opacity: 1; }
