:root {
  --eazo-safe-area-top: max(56px, env(safe-area-inset-top, 0px));
  --eazo-safe-area-bottom: max(34px, env(safe-area-inset-bottom, 0px));
  --warm: #f2cf94;
  --brass: #e0b25a;
  --ink: #ece2d0;
  --panel: rgba(30, 24, 17, 0.66);
  --border: rgba(224, 178, 90, 0.3);
}

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

html, body {
  height: 100%;
  background: #17110a;
  color: var(--ink);
  font-family: "Georgia", "Songti SC", "Noto Serif", serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

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

/* Top bar */
.topbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: var(--eazo-safe-area-top) 18px 8px;
  z-index: 10; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; flex-direction: column; line-height: 1.15; text-shadow: 0 2px 12px rgba(0,0,0,.7); }
.brand-title { font-size: 20px; letter-spacing: .04em; color: #f6ecd2; }
.brand-sub { font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: var(--brass); opacity: .85; }
.lang { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.lang-label { opacity: .7; }
.lang select {
  background: var(--panel); color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 8px; font-size: 12px; font-family: inherit; backdrop-filter: blur(8px);
}

/* Blocking overlays (only loader / webgl error) */
.overlay {
  position: absolute; inset: 0; z-index: 30;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; text-align: center; padding: 24px;
}
.overlay.solid { background: radial-gradient(120% 120% at 50% 30%, #241a11 0%, #140d06 70%); }
.overlay.hidden { display: none; }
.spinner {
  width: 46px; height: 46px; border-radius: 50%;
  border: 3px solid rgba(224,178,90,.25); border-top-color: var(--brass);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.panel { max-width: 380px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 24px; }
.panel h2 { color: var(--warm); margin-bottom: 10px; font-size: 20px; }
.panel p { font-size: 14px; opacity: .85; line-height: 1.6; }

/* Small non-blocking sound toast */
.toast {
  position: absolute; z-index: 25;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--eazo-safe-area-bottom) + 96px);
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--border); color: var(--warm);
  padding: 8px 14px; border-radius: 999px; font-size: 12px;
  backdrop-filter: blur(10px); box-shadow: 0 6px 22px rgba(0,0,0,.4);
  animation: floaty 2.2s ease-in-out infinite; pointer-events: none;
}
.toast.hidden { display: none; }
.toast-ico { display: inline-flex; color: var(--brass); }
@keyframes floaty { 0%,100%{opacity:.7; transform:translateX(-50%) translateY(0)} 50%{opacity:1; transform:translateX(-50%) translateY(-3px)} }

/* HUD */
.hud {
  position: absolute; left: 18px; right: 18px; z-index: 15;
  top: calc(var(--eazo-safe-area-top) + 46px);
  max-width: 340px; pointer-events: none;
}
.hud.hidden { display: none; }
.meter { display: flex; align-items: center; gap: 10px; }
.meter-label { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--brass); min-width: 62px; }
.meter-track { flex: 1; height: 7px; border-radius: 999px; overflow: hidden; background: rgba(0,0,0,.45); border: 1px solid var(--border); }
.meter-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #b9822b, var(--warm)); transition: width .3s ease; box-shadow: 0 0 12px rgba(242,207,148,.5); }
.status-row { margin-top: 8px; font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; text-shadow: 0 1px 8px rgba(0,0,0,.8); }
.status { color: #f6ecd2; }
.dot { opacity: .4; }
.melody-name { opacity: .82; }
.melody-name b { color: var(--warm); font-weight: normal; }
.hint { margin-top: 6px; font-size: 11px; opacity: .5; letter-spacing: .04em; }

/* Controls */
.controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  padding: 12px 14px calc(var(--eazo-safe-area-bottom) + 6px);
  background: linear-gradient(to top, rgba(15,10,5,.9), rgba(15,10,5,0));
}
.controls.hidden { display: none; }
.ctl {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 62px; padding: 8px 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  color: var(--ink); font-family: inherit; font-size: 11px; cursor: pointer;
  backdrop-filter: blur(8px); transition: transform .12s, border-color .2s, background .2s, color .2s;
  -webkit-tap-highlight-color: transparent;
}
.ctl .ico { width: 20px; height: 20px; display: block; fill: currentColor; }
.ctl:hover { border-color: var(--brass); transform: translateY(-2px); color: var(--warm); }
.ctl:active { transform: translateY(0) scale(.96); }
.ctl.primary { background: linear-gradient(180deg, rgba(224,178,90,.34), rgba(160,110,30,.4)); border-color: var(--brass); color: #fff2d8; }
.ctl.active { border-color: var(--warm); background: rgba(224,178,90,.26); color: var(--warm); }
.ctl:disabled { opacity: .4; cursor: not-allowed; transform: none; }

@media (max-width: 560px) {
  .ctl { min-width: 52px; padding: 7px 6px; }
  .ctl .lbl { font-size: 10px; }
  .brand-title { font-size: 17px; }
  .hud { top: calc(var(--eazo-safe-area-top) + 40px); }
}
