/* ============================================================
   SebasPresent — stylesheet (Slice 2)
   ============================================================ */

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: 'IM Fell English', 'Times New Roman', serif;
  color: #2a1f12;
  background: #0a0805;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

input { user-select: text; -webkit-user-select: text; }
button { font-family: inherit; cursor: pointer; }

:root {
  --parchment:        #d9c89a;
  --parchment-light:  #e8d8ab;
  --parchment-shadow: #b89e6c;
  --parchment-grain:  #c2a978;
  --stone-dark:       #2a201a;
  --stone-mid:        #3d2e22;
  --stone-light:      #5a4836;
  --ink-body:         #2a1f12;
  --ink-faint:        #5a4528;
  --osrs-red:         #8b1d1d;
  --osrs-blue:        #0d2a8b;
  --osrs-gold:        #c8a043;
  --osrs-gold-bright: #e8c560;

  --frame-radius: 4px;
  --shadow-deep: 0 24px 48px rgba(0,0,0,.75), 0 6px 18px rgba(0,0,0,.5);
}

.hidden { display: none !important; }

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ============================================================
   SPLASH
   ============================================================ */

.splash-screen { background: #0a0805; }

.splash-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 30%, #3a2818 0%, #1a1108 45%, #050302 100%),
    repeating-linear-gradient(45deg, transparent 0 3px, rgba(255,255,255,.012) 3px 6px);
  z-index: 0;
}

.splash-fog {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 20% 80%, rgba(180,150,80,.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(120,80,40,.08) 0%, transparent 50%);
  pointer-events: none;
  animation: drift 28s ease-in-out infinite alternate;
  z-index: 1;
}

@keyframes drift {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(2%, -1%) scale(1.05); }
}

.splash-content {
  position: relative;
  z-index: 2;
  text-align: center;
  animation: fade-up 1.2s ease-out;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.brand-title {
  font-family: 'Cinzel', serif;
  font-weight: 900;
  font-size: clamp(48px, 12vw, 110px);
  letter-spacing: 0.04em;
  margin: 0 0 12px;
  color: var(--osrs-gold-bright);
  text-shadow:
    0 0 1px #5a3a10,
    0 2px 0 #5a3a10,
    0 4px 0 #3a2408,
    0 6px 0 #2a1804,
    0 8px 16px rgba(0,0,0,.7),
    0 0 32px rgba(232,197,96,.3);
  line-height: 1;
}

.brand-tagline {
  font-family: 'IM Fell English', serif;
  font-style: italic;
  font-size: clamp(16px, 3.5vw, 22px);
  color: #c8a878;
  margin: 0 0 48px;
  letter-spacing: 0.08em;
  opacity: 0.85;
}

.splash-enter {
  font-size: clamp(16px, 3.5vw, 19px);
  padding: 14px 36px;
  min-width: 220px;
  animation: pulse-glow 2.4s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: var(--shadow-deep), 0 0 0 rgba(232,197,96,0); }
  50%      { box-shadow: var(--shadow-deep), 0 0 24px rgba(232,197,96,.4); }
}

/* ============================================================
   LOGIN + REGISTER
   ============================================================ */

.login-screen { background: #0a0805; }

.login-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 40%, #2a1f15 0%, #14100a 50%, #050302 100%),
    repeating-linear-gradient(45deg, transparent 0 4px, rgba(255,255,255,.008) 4px 8px);
  z-index: 0;
}

.login-bg::after {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 30% 70%, rgba(80,60,30,.15) 0%, transparent 40%),
    radial-gradient(circle at 70% 30%, rgba(100,70,40,.12) 0%, transparent 40%);
}

.parchment-frame {
  position: relative;
  z-index: 2;
  width: min(440px, calc(100vw - 32px));
  background: var(--parchment);
  border: 6px solid var(--stone-dark);
  border-radius: var(--frame-radius);
  box-shadow:
    var(--shadow-deep),
    inset 0 0 0 1px var(--stone-light),
    inset 0 0 0 3px var(--parchment-shadow),
    inset 0 0 60px rgba(120,80,30,.18);
  animation: fade-up 0.6s ease-out;
}

.parchment-frame::before {
  content: '';
  position: absolute;
  inset: 8px;
  pointer-events: none;
  border-radius: 2px;
  background:
    repeating-linear-gradient(0deg, transparent 0 2px, rgba(120,90,40,.025) 2px 3px),
    repeating-linear-gradient(90deg, transparent 0 2px, rgba(120,90,40,.02) 2px 3px),
    radial-gradient(ellipse at 30% 20%, rgba(150,110,60,.08) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(100,70,30,.1) 0%, transparent 60%);
  z-index: 0;
}

.parchment-corner {
  position: absolute;
  width: 14px; height: 14px;
  background: var(--stone-dark);
  border: 1px solid var(--stone-light);
  transform: rotate(45deg);
  z-index: 3;
  box-shadow: inset 0 0 0 2px var(--osrs-gold);
}
.parchment-corner.tl { top: -7px; left: -7px; }
.parchment-corner.tr { top: -7px; right: -7px; }
.parchment-corner.bl { bottom: -7px; left: -7px; }
.parchment-corner.br { bottom: -7px; right: -7px; }

.parchment-content {
  position: relative;
  z-index: 1;
  padding: 36px 32px 28px;
}

.osrs-heading {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 26px;
  text-align: center;
  margin: 0 0 24px;
  color: var(--osrs-red);
  text-shadow: 0 1px 0 var(--parchment-light);
  letter-spacing: 0.02em;
}

.osrs-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.osrs-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lbl-text {
  font-family: 'IM Fell English SC', serif;
  font-size: 15px;
  color: var(--ink-body);
  letter-spacing: 0.04em;
}

.lbl-hint {
  font-size: 12px;
  font-style: italic;
  color: var(--ink-faint);
  margin-top: 2px;
}

.osrs-input {
  background: rgba(255, 245, 220, 0.55);
  border: 2px solid var(--stone-dark);
  border-radius: 2px;
  padding: 10px 12px;
  font-family: 'IM Fell English', serif;
  font-size: 18px;
  color: var(--ink-body);
  outline: none;
  box-shadow: inset 0 2px 0 rgba(0,0,0,.18), inset 0 0 0 1px var(--parchment-shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.osrs-input:focus {
  border-color: var(--osrs-gold);
  box-shadow:
    inset 0 2px 0 rgba(0,0,0,.18),
    inset 0 0 0 1px var(--osrs-gold),
    0 0 0 3px rgba(200,160,67,.25);
}

.osrs-form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.osrs-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-family: 'Cinzel', serif;
  font-weight: 500;
  font-size: 17px;
  letter-spacing: 0.05em;
  border: 2px solid var(--stone-dark);
  border-radius: 3px;
  cursor: pointer;
  transition: transform 0.06s, filter 0.12s, box-shadow 0.12s;
  text-shadow: 0 1px 0 rgba(0,0,0,.4);
}

.osrs-btn-primary {
  background: linear-gradient(180deg, #6e5230 0%, #4a3620 50%, #382818 100%);
  color: var(--osrs-gold-bright);
  box-shadow:
    inset 0 1px 0 rgba(255,210,130,.3),
    inset 0 -2px 0 rgba(0,0,0,.4),
    0 3px 0 var(--stone-dark),
    0 6px 12px rgba(0,0,0,.5);
}

.osrs-btn-primary:hover { filter: brightness(1.15); }
.osrs-btn-primary:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 1px 0 rgba(255,210,130,.2),
    inset 0 -1px 0 rgba(0,0,0,.4),
    0 1px 0 var(--stone-dark),
    0 2px 6px rgba(0,0,0,.5);
}

.osrs-btn-ghost {
  background: linear-gradient(180deg, var(--parchment-light) 0%, var(--parchment) 50%, var(--parchment-shadow) 100%);
  color: var(--ink-body);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.4),
    inset 0 -2px 0 rgba(0,0,0,.18),
    0 2px 0 var(--stone-dark),
    0 4px 8px rgba(0,0,0,.4);
}

.osrs-btn-ghost:hover { filter: brightness(1.08); }
.osrs-btn-ghost:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.3),
    inset 0 -1px 0 rgba(0,0,0,.15),
    0 0 0 var(--stone-dark),
    0 2px 4px rgba(0,0,0,.4);
}

.osrs-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.osrs-error {
  margin: 4px 0 0;
  min-height: 22px;
  text-align: center;
  font-size: 15px;
  color: var(--osrs-red);
  font-style: italic;
}

.osrs-footnote {
  margin: 24px 0 0;
  text-align: center;
  font-size: 13px;
  font-style: italic;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}

.version-tag {
  position: fixed;
  bottom: 8px; left: 12px;
  font-family: 'IM Fell English', serif;
  font-size: 12px;
  color: rgba(200,170,120,.45);
  z-index: 10;
  pointer-events: none;
}

/* ============================================================
   WORLD SCREEN — the 3D scene + HUD overlay
   ============================================================ */

.world-screen {
  background: #050302;  /* fallback while Three.js loads */
}

#worldCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* HUD overlay: positioned absolutely on top, allows clicks through except on its children */
.world-hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.world-hud > * { pointer-events: auto; }

.world-hud-top {
  position: absolute;
  top: env(safe-area-inset-top, 0px);
  left: 0; right: 0;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.world-hud-btn {
  background: linear-gradient(180deg, #3a2a1a 0%, #20140a 100%);
  border: 2px solid var(--stone-dark);
  color: var(--osrs-gold-bright);
  font-family: 'Cinzel', serif;
  font-size: 14px;
  letter-spacing: 0.04em;
  padding: 8px 14px;
  border-radius: 4px;
  box-shadow:
    inset 0 1px 0 rgba(255,210,130,.25),
    0 2px 6px rgba(0,0,0,.5);
  cursor: pointer;
}

.world-hud-btn:active {
  transform: translateY(1px);
  filter: brightness(1.1);
}

.world-hud-pill {
  background: rgba(20, 14, 8, 0.72);
  border: 1px solid rgba(200, 170, 120, 0.3);
  color: rgba(200, 170, 120, 0.85);
  font-family: 'IM Fell English', serif;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.world-hint {
  position: absolute;
  bottom: max(70px, env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  font-family: 'IM Fell English', serif;
  font-style: italic;
  font-size: 14px;
  color: rgba(255, 240, 200, 0.7);
  text-shadow: 0 1px 4px rgba(0,0,0,.8);
  pointer-events: none;
  animation: hint-fade 8s ease-out forwards;
}

@keyframes hint-fade {
  0%   { opacity: 0; }
  10%  { opacity: 1; }
  70%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Floating name tag — DOM, positioned by JS each frame */
.player-name-tag {
  position: absolute;
  transform: translate(-50%, -100%);
  background: rgba(20, 14, 8, 0.78);
  border: 1px solid rgba(200, 170, 120, 0.45);
  color: var(--osrs-gold-bright);
  font-family: 'IM Fell English SC', serif;
  font-size: 14px;
  padding: 3px 10px;
  border-radius: 3px;
  text-shadow: 0 1px 2px rgba(0,0,0,.9);
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
}

/* Virtual joystick — bottom-left for mobile */
.joystick {
  display: none;
  position: absolute;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  left: 28px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%,
    rgba(200, 170, 120, 0.15) 0%,
    rgba(20, 14, 8, 0.6) 100%);
  border: 2px solid rgba(200, 170, 120, 0.4);
  touch-action: none;
  z-index: 20;
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
}

.joystick-knob {
  position: absolute;
  top: 50%; left: 50%;
  width: 44px; height: 44px;
  margin-left: -22px;
  margin-top: -22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%,
    #e8c560 0%,
    #8b6420 70%,
    #4a3618 100%);
  border: 2px solid var(--stone-dark);
  box-shadow:
    inset 0 2px 0 rgba(255, 230, 170, 0.4),
    0 2px 6px rgba(0,0,0,.6);
  pointer-events: none;
  transition: transform 0.05s ease-out;
}

/* Show joystick only on touch devices */
@media (pointer: coarse), (max-width: 800px) {
  .joystick { display: block; }
}

/* World loading veil */
.world-loading {
  position: absolute;
  inset: 0;
  background: #0a0805;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  z-index: 50;
}

.world-loading .loading-text {
  font-family: 'Cinzel', serif;
  font-size: 16px;
  color: var(--osrs-gold-bright);
  letter-spacing: 0.08em;
}

/* ============================================================
   GLOBAL LOADING OVERLAY
   ============================================================ */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  z-index: 100;
}

.loading-spinner {
  width: 48px; height: 48px;
  border: 4px solid rgba(200,170,120,.25);
  border-top-color: var(--osrs-gold-bright);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay .loading-text {
  font-family: 'Cinzel', serif;
  font-size: 16px;
  color: var(--osrs-gold-bright);
  letter-spacing: 0.08em;
}

/* ============================================================
   Mobile tweaks
   ============================================================ */

@media (max-width: 480px) {
  .parchment-content { padding: 28px 22px 22px; }
  .osrs-heading { font-size: 22px; margin-bottom: 18px; }
  .osrs-input { font-size: 17px; }
  .osrs-btn { font-size: 15px; padding: 11px 20px; }
}

@supports (-webkit-touch-callout: none) {
  .osrs-input { font-size: 16px; }
}
