/* ===== Base styles shared by every screen (Drops-like minimal, misty blue + wheat gold) ===== */
:root {
  --ink: #26355a;
  --sub: #6a7ea6;
  --mist: #eaf2fb;
  --blue: #5b8def;
  --azure: #3f6fd8;
  --sky: #9cc7ff;
  --gold: #e8b45a;
  --gold-d: #c98f2e;
  --rose: #ef7a8a;
  --mint: #44c4a0;
  --violet: #9a7cf0;
  --card: rgba(255, 255, 255, 0.78);
  --card-line: rgba(140, 170, 220, 0.35);
  --shadow: 0 8px 24px rgba(40, 70, 130, 0.14);
  --r: 20px;
  --font: system-ui, "Segoe UI", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #dfeaf8; color: var(--ink);
  font-family: var(--font); user-select: none; -webkit-user-select: none; touch-action: manipulation; }
#app { position: fixed; inset: 0; overflow: hidden; }
button { font-family: inherit; color: inherit; }

/* screens */
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: block; animation: screenIn 0.32s cubic-bezier(.2,1.3,.4,1) both; }
@keyframes screenIn { from { opacity: 0; transform: scale(1.03); } to { opacity: 1; transform: none; } }

/* panel: 9-slice from ui-panel art */
.panel {
  border-style: solid; border-width: 18px;
  border-image: url("../assets/ui-panel.webp") 64 fill / 18px stretch;
  background-clip: padding-box;
}
.card {
  background: var(--card); border: 1px solid var(--card-line); border-radius: var(--r);
  box-shadow: var(--shadow); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}

/* buttons: 9-slice from ui-button art */
.btn {
  appearance: none; border: 0; cursor: pointer; position: relative;
  min-height: 52px; min-width: 120px; padding: 0 22px;
  border-style: solid; border-width: 12px 16px;
  border-image: url("../assets/ui-button.webp") 40 fill / 12px 16px stretch;
  background: transparent; color: #fff; font-weight: 800; font-size: 18px; letter-spacing: 0.02em;
  text-shadow: 0 2px 0 rgba(20, 40, 100, 0.45), 0 0 1px rgba(20, 40, 100, 0.8);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.12s cubic-bezier(.2,1.6,.4,1), filter 0.15s;
  filter: drop-shadow(0 6px 10px rgba(40, 80, 170, 0.25));
}
.btn:active, .btn.pressed { transform: scale(0.94); }
.btn.gold { filter: hue-rotate(185deg) saturate(1.3) brightness(1.08) drop-shadow(0 6px 10px rgba(170, 120, 40, 0.3)); }
.btn.ghost {
  border: 2px solid var(--card-line); border-image: none; border-radius: 16px; background: rgba(255,255,255,0.7);
  color: var(--ink); text-shadow: none; filter: none; box-shadow: var(--shadow);
}
.btn .ico { width: 22px; height: 22px; }
.icon-btn {
  appearance: none; border: 0; cursor: pointer; width: 48px; height: 48px; padding: 0;
  background: url("../assets/ui-pause.webp") center / 100% 100% no-repeat; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; color: #fff;
  transition: transform 0.12s cubic-bezier(.2,1.6,.4,1);
}
.icon-btn.plate { background-image: none; background: linear-gradient(160deg, #7fb0ff, #3f6fd8);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.6), 0 4px 10px rgba(40,80,170,0.3); }
.icon-btn:active { transform: scale(0.9); }
.icon-btn svg { width: 26px; height: 26px; }
.corner-tr { position: absolute; top: calc(10px + var(--safe-t)); right: 10px; z-index: 5; }

/* keyboard / gamepad focus (Nav) */
.nav-focus { outline: 3px solid var(--gold) !important; outline-offset: 3px; transform: scale(1.04); z-index: 3; }

/* modals */
#modals { position: absolute; inset: 0; pointer-events: none; z-index: 50; }
.modal-wrap { position: absolute; inset: 0; pointer-events: auto; display: flex; align-items: center; justify-content: center;
  background: rgba(30, 50, 90, 0.35); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease both; padding: 16px; }
.modal-wrap.closing { animation: fadeOut 0.18s ease both; }
.modal { width: min(94%, 420px); max-height: 92%; overflow-y: auto; animation: popIn 0.3s cubic-bezier(.2,1.4,.4,1) both;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(236,244,255,0.96)); border-radius: 26px;
  box-shadow: 0 20px 50px rgba(30, 60, 120, 0.3); border: 1px solid rgba(255,255,255,0.9); padding: 22px 20px; }
@keyframes popIn { from { transform: scale(0.82); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

#toast { position: absolute; left: 50%; top: calc(74px + var(--safe-t)); transform: translateX(-50%); z-index: 80;
  pointer-events: none; }
.toast-item { background: rgba(38, 53, 90, 0.9); color: #fff; padding: 10px 18px; border-radius: 14px; font-weight: 700;
  font-size: 15px; margin-top: 6px; animation: popIn 0.25s cubic-bezier(.2,1.4,.4,1) both; text-align: center; max-width: 86vw; }

/* title screen */
#title { cursor: pointer; overflow: hidden; }
.title-bg { position: absolute; inset: -3%; background: #cfe0f5 url("../assets/cover-bg.webp") center / cover no-repeat;
  animation: titleDrift 18s ease-in-out infinite alternate; }
@keyframes titleDrift { from { transform: scale(1.02) translateY(0); } to { transform: scale(1.07) translateY(-1.5%); } }
.title-mist { position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0) 35%, rgba(255,255,255,0) 70%, rgba(234,242,251,0.75) 100%); }
.title-logo { position: absolute; left: 50%; top: calc(7% + var(--safe-t)); width: 82%; max-height: 30%; object-fit: contain;
  transform: translateX(-50%); filter: drop-shadow(0 6px 16px rgba(30, 60, 120, 0.25));
  animation: logoIn 0.7s cubic-bezier(.2,1.5,.4,1) 0.15s both, logoFloat 4s ease-in-out 1s infinite; }
@keyframes logoIn { from { opacity: 0; transform: translateX(-50%) translateY(-30px) scale(0.8); } to { opacity: 1; transform: translateX(-50%) scale(1); } }
@keyframes logoFloat { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-6px); } }
.title-prompt { position: absolute; left: 50%; bottom: calc(9% + var(--safe-b)); transform: translateX(-50%); white-space: nowrap;
  padding: 12px 26px; border-radius: 999px; background: rgba(255,255,255,0.72); color: var(--ink); font-weight: 800; font-size: 17px;
  box-shadow: 0 6px 20px rgba(40, 70, 130, 0.18); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: promptPulse 1.8s ease-in-out infinite; }
@keyframes promptPulse { 0%, 100% { opacity: 1; transform: translateX(-50%) scale(1); } 50% { opacity: 0.75; transform: translateX(-50%) scale(0.97); } }
#title.leaving .title-prompt { opacity: 0; transition: opacity .2s; animation: none; }
#title.leaving .corner-tr { display: none; }

h1, h2, h3 { margin: 0; font-weight: 900; }
.muted { color: var(--sub); }
.crest-icon { display: block; }
::-webkit-scrollbar { width: 0; height: 0; }
