/* ============================================================
   THEME CONFIGURATION — Edit this section to change the look
   ============================================================ */
:root {
  /* --- Game identity --- */
  --game-title: "Retcon Girlfriend";

  /* --- Positional Offsets --- */
  --sprite-bottom-offset: -45%; /* X% offset for sprites from the bottom */

  /* --- Palette --- */
  --color-bg:            #0d0d12;
  --color-surface:       rgba(15, 15, 22, 0.92);
  --color-surface2:      rgba(255,255,255,0.04);
  --color-border:        rgba(255,255,255,0.10);
  --color-accent:        #e8c97a;
  --color-accent2:       #7ab8e8;
  --color-text:          #e8e4da;
  --color-text-dim:      rgba(232, 228, 218, 0.55);
  --color-name-default:  #e8e4da;
  --color-choice-bg:     rgba(20, 20, 32, 0.88);
  --color-choice-hover:  rgba(232, 201, 122, 0.15);
  --color-choice-border: rgba(232, 201, 122, 0.4);
  --color-overlay:       rgba(0,0,0,0.72);
  --color-placeholder-bg:#1a1a2e;
  --color-placeholder-border: rgba(232,201,122,0.5);

  /* --- Typography --- */
  --font-display:  'Cormorant Garamond', 'Palatino Linotype', Georgia, serif;
  --font-ui:       'Josefin Sans', 'Century Gothic', Futura, sans-serif;
  --font-body:     'Lora', Georgia, serif;
  --font-size-base: 17px;
  --font-size-name: 15px;
  --font-size-choice: 15px;

  /* --- Dialogue box --- */
  --dialogue-height: 32%;
  --dialogue-padding: 22px 28px 18px;
  --dialogue-radius:  4px;
  --dialogue-backdrop: blur(12px);
  --name-tag-radius: 3px 3px 0 0;

  /* --- Transitions --- */
  --fade-scene: 0.6s;
  --fade-sprite: 0.35s;
  --fade-dialogue: 0.22s;

  /* --- Menu --- */
  --menu-bg: linear-gradient(160deg, #0d0d14 0%, #111118 60%, #0a0a10 100%);

  /* --- Save slots --- */
  --save-slots: 9;
}

/* ============================================================
   GOOGLE FONTS IMPORT
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;1,300;1,400&family=Josefin+Sans:wght@300;400;600&family=Lora:ital,wght@0,400;0,500;1,400&display=swap');

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #000;
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  color: var(--color-text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }

/* ============================================================
   GAME CONTAINER
   ============================================================ */
#game-container {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#viewport {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: calc(100vh * 16 / 9);
  max-height: calc(100vw * 9 / 16);
  overflow: hidden;
  background: var(--color-bg);
}

/* ============================================================
   SCREENS
   ============================================================ */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}
.screen.active { display: flex; }

/* ============================================================
   MAIN MENU SCREEN
   ============================================================ */
#screen-menu { background: var(--menu-bg); align-items: center; justify-content: center; }
.menu-bg-art { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.menu-bg-art::before { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse 60% 80% at 75% 50%, rgba(122,184,232,0.07) 0%, transparent 70%), radial-gradient(ellipse 40% 60% at 25% 60%, rgba(232,201,122,0.05) 0%, transparent 70%); }
.menu-bg-art::after { content: ''; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px); background-size: 60px 60px; }
.menu-content { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 0; width: 100%; }
.menu-title-block { text-align: center; margin-bottom: 52px; }
.menu-eyebrow { font-family: var(--font-ui); font-size: 10px; letter-spacing: 0.35em; text-transform: uppercase; color: var(--color-accent); opacity: 0.7; margin-bottom: 12px; }
.menu-title { font-family: var(--font-display); font-size: clamp(28px, 6vw, 52px); font-weight: 300; letter-spacing: 0.05em; color: var(--color-text); line-height: 1.1; }
.menu-title em { font-style: italic; color: var(--color-accent); }
.menu-title-line { width: 48px; height: 1px; background: linear-gradient(90deg, transparent, var(--color-accent), transparent); margin: 16px auto 0; }
.menu-buttons { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 220px; }
.menu-btn { width: 100%; max-width: 240px; padding: 11px 32px; font-family: var(--font-ui); font-size: 12px; font-weight: 400; letter-spacing: 0.2em; text-transform: uppercase; color: var(--color-text); border: 1px solid transparent; border-radius: 2px; background: transparent; transition: all 0.2s; text-align: center; position: relative; overflow: hidden; }
.menu-btn::before { content: ''; position: absolute; inset: 0; background: var(--color-accent); opacity: 0; transition: opacity 0.2s; }
.menu-btn:hover::before, .menu-btn:active::before { opacity: 0.08; }
.menu-btn:hover, .menu-btn:active { border-color: rgba(232,201,122,0.35); color: var(--color-accent); }
.menu-btn.primary { border-color: rgba(232,201,122,0.4); color: var(--color-accent); }
.menu-btn.primary:hover, .menu-btn.primary:active { border-color: var(--color-accent); background: rgba(232,201,122,0.08); }
.menu-btn:disabled { opacity: 0.3; pointer-events: none; }
.menu-version { position: absolute; bottom: 14px; right: 18px; font-family: var(--font-ui); font-size: 9px; letter-spacing: 0.15em; color: var(--color-text-dim); opacity: 0.4; }

/* ============================================================
   LOADING SCREEN
   ============================================================ */
#screen-loading { background: var(--color-bg); align-items: center; justify-content: center; gap: 16px; }
.loading-spinner { width: 36px; height: 36px; border: 2px solid var(--color-border); border-top-color: var(--color-accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-family: var(--font-ui); font-size: 10px; letter-spacing: 0.25em; text-transform: uppercase; color: var(--color-text-dim); }
.loading-error { font-family: var(--font-body); font-size: 14px; color: #ff8080; text-align: center; max-width: 340px; line-height: 1.6; padding: 0 20px; }

/* ============================================================
   GAME SCREEN
   ============================================================ */
#screen-game { background: #000; }

/* Scene / background layer */
#scene-layer {
  position: absolute;
  inset: 0;
  background: #111;
  transition: opacity var(--fade-scene) ease;
  display: flex;
  justify-content: center;
  align-items: center;
}
#scene-layer canvas, #scene-layer img {
  height: 100%;
  width: auto;
  display: block;
}

/* Sprite layer */
#sprite-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Sprite Anchor System */
.sprite-slot {
  position: absolute;
  bottom: var(--sprite-bottom-offset);
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: opacity var(--fade-sprite) ease;
}
/* Anchored horizontally by their centers */
.sprite-slot.left  { left: 20%; transform: translateX(-50%); }
.sprite-slot.center{ left: 50%; transform: translateX(-50%); }
.sprite-slot.right { left: 80%; transform: translateX(-50%); }

.sprite-slot img {
  width: auto;
  display: block;
  image-rendering: auto;
}

.sprite-placeholder {
  width: 160px; height: 260px; background: var(--color-placeholder-bg); border: 2px dashed var(--color-placeholder-border); border-radius: 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 12px; text-align: center; gap: 8px;
}
.sprite-placeholder .ph-icon { font-size: 28px; opacity: 0.6; }
.sprite-placeholder .ph-label { font-family: var(--font-ui); font-size: 10px; letter-spacing: 0.1em; color: var(--color-accent); opacity: 0.8; word-break: break-all; }

/* Scene placeholder */
.scene-placeholder { width: 100%; height: 100%; background: linear-gradient(135deg, #0d0d18 0%, #111120 100%); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.scene-placeholder .ph-icon { font-size: 36px; opacity: 0.3; }
.scene-placeholder .ph-label { font-family: var(--font-ui); font-size: 11px; letter-spacing: 0.12em; color: var(--color-accent); opacity: 0.5; }

/* Dialogue box */
#dialogue-box { position: absolute; bottom: 0; left: 0; right: 0; height: var(--dialogue-height); padding: var(--dialogue-padding); background: var(--color-surface); backdrop-filter: var(--dialogue-backdrop); -webkit-backdrop-filter: var(--dialogue-backdrop); border-top: 1px solid var(--color-border); display: flex; flex-direction: column; gap: 8px; transition: opacity var(--fade-dialogue); z-index: 10; }
#dialogue-box.hidden { opacity: 0; pointer-events: none; }
#name-tag { font-family: var(--font-ui); font-size: var(--font-size-name); font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--color-name-default); min-height: 1.4em; display: flex; align-items: center; }
#name-tag:empty { display: none; }
#dialogue-text { font-family: var(--font-body); font-size: var(--font-size-base); line-height: 1.65; color: var(--color-text); flex: 1; overflow: hidden; }
#continue-indicator { position: absolute; bottom: 10px; right: 18px; font-size: 13px; color: var(--color-accent); opacity: 0; animation: blink-indicator 1.2s ease-in-out infinite; }
@keyframes blink-indicator { 0%, 100% { opacity: 0; } 50% { opacity: 0.9; } }
#continue-indicator.show { animation-play-state: running; opacity: 1; }

/* Choice overlay */
#choice-overlay { position: absolute; inset: 0; background: var(--color-overlay); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; z-index: 20; padding: 24px; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
#choice-overlay.active { opacity: 1; pointer-events: all; }
#choice-buttons { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.choice-prompt { font-family: var(--font-display); font-size: 16px; font-style: italic; color: var(--color-text-dim); margin-bottom: 8px; letter-spacing: 0.04em; }
.choice-btn { width: 100%; max-width: 480px; padding: 13px 24px; background: var(--color-choice-bg); border: 1px solid var(--color-choice-border); border-radius: 3px; font-family: var(--font-body); font-size: var(--font-size-choice); color: var(--color-text); text-align: center; line-height: 1.4; transition: all 0.18s; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.choice-btn:hover, .choice-btn:active { background: var(--color-choice-hover); border-color: var(--color-accent); color: var(--color-accent); transform: translateY(-1px); }

/* Top menu bar (in-game) */
#game-topbar { position: absolute; top: 0; left: 0; right: 0; height: 36px; display: flex; align-items: center; justify-content: flex-end; padding: 0 12px; gap: 6px; z-index: 30; background: linear-gradient(to bottom, rgba(0,0,0,0.5), transparent); opacity: 0; transition: opacity 0.3s; }
#game-topbar.show { opacity: 1; }
.topbar-btn { font-family: var(--font-ui); font-size: 9px; letter-spacing: 0.15em; text-transform: uppercase; color: rgba(255,255,255,0.6); padding: 4px 10px; border: 1px solid rgba(255,255,255,0.15); border-radius: 2px; background: rgba(0,0,0,0.3); transition: all 0.18s; }
.topbar-btn:hover, .topbar-btn:active { color: var(--color-accent); border-color: rgba(232,201,122,0.4); }

/* Fade overlay for scene transitions */
#fade-overlay { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 50; transition: opacity var(--fade-scene) ease; }
#fade-overlay.fading { opacity: 1; }

/* ============================================================
   SAVE / LOAD / SETTINGS / CONFIRM
   ============================================================ */
#screen-save, #screen-load, #screen-settings { background: rgba(10,10,16,0.97); backdrop-filter: blur(20px); z-index: 60; }
.saveload-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px 12px; border-bottom: 1px solid var(--color-border); flex-shrink: 0; }
.saveload-title { font-family: var(--font-display); font-size: 22px; font-weight: 300; letter-spacing: 0.08em; color: var(--color-text); }
.saveload-title em { font-style: italic; color: var(--color-accent); }
.saveload-close { font-family: var(--font-ui); font-size: 10px; letter-spacing: 0.2em; color: var(--color-text-dim); padding: 6px 14px; border: 1px solid var(--color-border); border-radius: 2px; transition: all 0.18s; }
.saveload-close:hover { color: var(--color-accent); border-color: rgba(232,201,122,0.4); }
.slot-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 14px 20px; overflow-y: auto; flex: 1; }
.save-slot { background: var(--color-surface2); border: 1px solid var(--color-border); border-radius: 4px; padding: 12px 10px; display: flex; flex-direction: column; gap: 5px; cursor: pointer; transition: all 0.18s; min-height: 80px; position: relative; overflow: hidden; }
.save-slot:hover, .save-slot:active { border-color: rgba(232,201,122,0.4); background: rgba(232,201,122,0.04); }
.save-slot.empty { align-items: center; justify-content: center; opacity: 0.4; }
.save-slot.empty:hover { opacity: 0.7; }
.slot-number { font-family: var(--font-ui); font-size: 9px; letter-spacing: 0.18em; color: var(--color-accent); opacity: 0.7; }
.slot-scene { font-family: var(--font-body); font-size: 11px; color: var(--color-text); line-height: 1.4; flex: 1; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.slot-date { font-family: var(--font-ui); font-size: 9px; color: var(--color-text-dim); letter-spacing: 0.08em; }
.slot-empty-label { font-family: var(--font-ui); font-size: 10px; letter-spacing: 0.15em; color: var(--color-text-dim); }
.slot-delete-btn { position: absolute; top: 4px; right: 4px; font-size: 10px; color: rgba(255,80,80,0.4); padding: 2px 5px; border: 1px solid rgba(255,80,80,0.2); border-radius: 2px; display: none; transition: all 0.15s; }
.save-slot:hover .slot-delete-btn { display: block; }
.slot-delete-btn:hover { color: rgba(255,80,80,0.9); border-color: rgba(255,80,80,0.6); }

.settings-body { padding: 16px 24px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 18px; }
.settings-section { display: flex; flex-direction: column; gap: 10px; }
.settings-section-title { font-family: var(--font-ui); font-size: 9px; letter-spacing: 0.25em; text-transform: uppercase; color: var(--color-accent); opacity: 0.7; padding-bottom: 6px; border-bottom: 1px solid var(--color-border); }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.settings-label { font-family: var(--font-ui); font-size: 11px; letter-spacing: 0.1em; color: var(--color-text); flex: 1; }
.settings-slider { -webkit-appearance: none; appearance: none; width: 140px; height: 3px; background: var(--color-border); border-radius: 2px; outline: none; }
.settings-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--color-accent); cursor: pointer; border: none; }
.settings-toggle { width: 40px; height: 22px; background: var(--color-border); border-radius: 11px; position: relative; cursor: pointer; transition: background 0.2s; flex-shrink: 0; }
.settings-toggle.on { background: rgba(232,201,122,0.6); }
.settings-toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.settings-toggle.on::after { transform: translateX(18px); }

#confirm-dialog { position: absolute; inset: 0; background: rgba(0,0,0,0.7); display: none; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(4px); }
#confirm-dialog.active { display: flex; }
.confirm-box { background: #111118; border: 1px solid var(--color-border); border-radius: 6px; padding: 28px 32px; max-width: 320px; width: 90%; display: flex; flex-direction: column; gap: 18px; align-items: center; text-align: center; }
.confirm-message { font-family: var(--font-display); font-size: 16px; color: var(--color-text); line-height: 1.5; }
.confirm-buttons { display: flex; gap: 10px; width: 100%; }
.confirm-btn { flex: 1; padding: 10px 0; font-family: var(--font-ui); font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; border: 1px solid var(--color-border); border-radius: 2px; transition: all 0.18s; }
.confirm-btn.yes { border-color: rgba(232,201,122,0.5); color: var(--color-accent); }
.confirm-btn.yes:hover { background: rgba(232,201,122,0.1); }
.confirm-btn.no { color: var(--color-text-dim); }
.confirm-btn.no:hover { border-color: rgba(255,255,255,0.25); color: var(--color-text); }

#toast { position: absolute; top: 48px; left: 50%; transform: translateX(-50%) translateY(-10px); background: rgba(232,201,122,0.12); border: 1px solid rgba(232,201,122,0.3); color: var(--color-accent); font-family: var(--font-ui); font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase; padding: 8px 20px; border-radius: 2px; z-index: 200; opacity: 0; pointer-events: none; transition: all 0.3s; white-space: nowrap; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }
.italic { font-style: italic; }
.bold   { font-weight: bold; }
