/* tiup huruf — terminal/coder aesthetic, mobile-first.
   Everything monospaced, dark phosphor palette, controls as a bottom sheet
   on small screens and a floating panel on larger ones. */

:root {
  --bg: #050608;
  --ink: #b9f5c8;          /* phosphor green text */
  --ink-dim: #4f7a5c;
  --accent: #6cf0a8;
  --amber: #ffcf6b;
  --panel: rgba(8, 12, 10, 0.92);
  --line: rgba(108, 240, 168, 0.22);
  --mono: "Courier New", "DejaVu Sans Mono", "Liberation Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* The curtain fills everything and swallows all touch gestures. */
#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;        /* we own the swipe; no scroll/zoom */
  background:
    radial-gradient(120% 80% at 50% -10%, #0b1410 0%, var(--bg) 60%);
  cursor: crosshair;
}

/* ---- first-run hint ---- */
#hint {
  position: fixed;
  left: 50%;
  bottom: max(5.5rem, env(safe-area-inset-bottom) + 5rem);
  transform: translateX(-50%);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  pointer-events: none;
  text-transform: lowercase;
  opacity: 0;
  animation: hintIn 0.8s ease 0.6s forwards, hintPulse 2.6s ease-in-out 1.6s infinite;
  text-shadow: 0 0 12px rgba(108, 240, 168, 0.25);
}
#hint.gone { animation: hintOut 0.5s ease forwards; }
@keyframes hintIn { to { opacity: 0.85; } }
@keyframes hintOut { to { opacity: 0; visibility: hidden; } }
@keyframes hintPulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.85; } }

/* ---- wind HUD (arrow + strength bar) ---- */
#hud {
  position: fixed;
  top: max(0.9rem, env(safe-area-inset-top));
  right: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
  opacity: 0.0;
  transition: opacity 0.3s ease;
}
#hud.active { opacity: 0.9; }
#wind-arrow {
  font-size: 1.3rem;
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent);
  transform-origin: 50% 50%;
  will-change: transform;
}
#wind-bar {
  width: 78px;
  height: 6px;
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  background: rgba(0,0,0,0.4);
}
#wind-bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--amber));
  box-shadow: 0 0 8px var(--accent);
  transition: width 0.08s linear;
}

/* ---- panel toggle (FAB) ---- */
#panel-toggle {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(1rem, env(safe-area-inset-bottom) + 0.6rem);
  z-index: 20;
  font-family: var(--mono);
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1.15rem;
  cursor: pointer;
  box-shadow: 0 4px 22px rgba(108, 240, 168, 0.35);
  transition: transform 0.18s ease, opacity 0.18s ease;
}
#panel-toggle .bracket { opacity: 0.6; }
#panel-toggle:active { transform: translateX(-50%) scale(0.95); }
#panel-toggle.hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(140%); }

/* ---- panel ---- */
#panel {
  position: fixed;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--panel);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  padding: 0.6rem 1rem calc(1rem + env(safe-area-inset-bottom));
  transform: translateY(110%);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 -12px 40px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 82vh;
  overflow-y: auto;
}
#panel[data-open="true"] { transform: translateY(0); }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 0.45rem;
  margin-bottom: 0.2rem;
}
.panel-head .prompt {
  color: var(--ink-dim);
  font-size: 0.82rem;
}
.panel-head .prompt::before { content: "$ "; color: var(--accent); }
#panel-close {
  background: none;
  border: none;
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.3rem;
}

.row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.row label {
  font-size: 0.78rem;
  color: var(--ink-dim);
  text-transform: lowercase;
  letter-spacing: 0.04em;
}
.row label em {
  font-style: normal;
  color: var(--ink);
}

/* range inputs */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  background: var(--line);
  border-radius: 3px;
}
input[type="range"]::-moz-range-track {
  height: 3px;
  background: var(--line);
  border-radius: 3px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(108, 240, 168, 0.6);
  border: 2px solid #08120d;
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #08120d;
}

/* buttons */
button.ghost {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--ink);
  background: rgba(108, 240, 168, 0.06);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}
button.ghost:hover { background: rgba(108, 240, 168, 0.14); }
button.ghost:active { transform: scale(0.98); }

.field { display: flex; }
.field button { width: 100%; }

/* segmented controls */
.seg {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.seg button {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--ink-dim);
  background: transparent;
  border: none;
  padding: 0.55rem 0.4rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: none; }
.seg button.on {
  color: var(--bg);
  background: var(--accent);
  font-weight: bold;
}

.row.actions {
  flex-direction: row;
  gap: 0.5rem;
}
.row.actions button { flex: 1; text-align: center; }

.panel-foot {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--ink-dim);
  border-top: 1px dashed var(--line);
  padding-top: 0.45rem;
  margin-top: 0.1rem;
}

/* drag-over highlight on the whole stage */
body.dropping #stage { box-shadow: inset 0 0 0 3px var(--accent); }
body.dropping::after {
  content: "drop image to weave the curtain";
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  color: var(--accent);
  background: rgba(5, 8, 10, 0.55);
  z-index: 50;
  pointer-events: none;
  letter-spacing: 0.06em;
}

/* error / unsupported card */
#fatal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 2rem;
  text-align: center;
  z-index: 100;
  background: var(--bg);
}
#fatal div {
  max-width: 32rem;
  line-height: 1.6;
  color: var(--ink);
}
#fatal code { color: var(--amber); }

/* Larger screens: panel becomes a floating left card. */
@media (min-width: 720px) {
  #panel {
    left: 1rem;
    right: auto;
    top: 1rem;
    bottom: auto;
    width: 320px;
    border-radius: 14px;
    border: 1px solid var(--line);
    transform: translateX(calc(-100% - 1.5rem));
    max-height: calc(100vh - 2rem);
  }
  #panel[data-open="true"] { transform: translateX(0); }
  #panel-toggle {
    left: 1rem;
    transform: none;
    bottom: auto;
    top: 1rem;
  }
  #panel-toggle:active { transform: scale(0.95); }
  #panel-toggle.hidden { transform: translateX(-140%); }
  #hint { bottom: 2.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  #hint { animation: hintIn 0.4s ease forwards; }
}
