/* Asche zu Asche — native browser port styles. Dark RammWiki-adjacent theme,
   a 4:3 letterboxed stage, and touch controls that overlay the screen. */

:root {
  color-scheme: dark;
  --ink: #deded7;
  --dim: #afafa7;
  --accent: #d3c998;
  --panel: rgba(15, 16, 15, 0.88);
  --line: #3a3b32;
  --button: #33362d;
  --button-line: #6c6d58;
  --button-hover: #454939;
  --primary: #4b5138;
  --primary-line: #8c8f6b;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font: 16px/1.6 system-ui, sans-serif;
  background: #131414;
  color: var(--ink);
}

a { color: var(--accent); }

.shell {
  max-width: 1040px;
  margin: auto;
  padding: 30px 22px 48px;
}

.eyebrow {
  margin: 0;
  color: #aeaa87;
  font-size: .75rem;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1 {
  margin: 10px 0 14px;
  font-size: clamp(2rem, 6vw, 3.4rem);
  line-height: 1.1;
}

.intro { color: var(--dim); margin: 0 0 22px; }

/* ------------------------------------------------------------------ stage */
.stage {
  position: relative;
  background: #000;
  border: 1px solid #555649;
}

.screen {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  overflow: hidden;
}

.screen canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
}

.screen canvas:focus-visible { outline: 3px solid #c9c482; outline-offset: -3px; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(10px, 3vw, 26px);
  background: radial-gradient(ellipse at center, rgba(24, 26, 20, .72), rgba(6, 7, 6, .92) 80%);
  overflow: auto;
  pointer-events: auto;
}

.overlay[hidden], .panel[hidden], .boot[hidden], .touch-controls[hidden] { display: none; }

.boot { text-align: center; color: var(--dim); }

.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 12px;
  border: 3px solid #454c3a;
  border-top-color: #d3cf91;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.panel {
  width: min(560px, 100%);
  max-height: 100%;
  padding: clamp(14px, 3vw, 26px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
  overflow: auto;
}

.panel h2 { margin: 0 0 6px; font-size: clamp(1.4rem, 4.5vw, 2rem); }
.panel p { margin: 8px 0; color: var(--dim); font-size: .95rem; }
.panel .tagline { color: var(--accent); }

.panel .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 14px 0 4px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: center;
  padding: 0;
  margin: 10px 0;
  list-style: none;
  font-size: .92rem;
}

kbd {
  padding: 2px 7px;
  border: 1px solid #676858;
  border-bottom-width: 3px;
  border-radius: 4px;
  background: #23251e;
  font: inherit;
  margin-right: 2px;
}

.best { color: var(--accent); }
.original-link .note { color: #8f9089; }
.kicker {
  margin: 0;
  color: #aeaa87;
  font-size: .75rem;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.breakdown { margin: 12px auto 4px; max-width: 420px; text-align: left; }
.breakdown > div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 0;
  border-bottom: 1px dashed #34352c;
}
.breakdown dt { color: var(--dim); }
.breakdown dd { margin: 0; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.breakdown .total { border-bottom: 0; margin-top: 4px; }
.breakdown .total dt { color: var(--accent); }
.breakdown .total dd { color: #ffe98a; font-weight: 700; }
.next { color: var(--dim); }
.note { font-size: .85rem !important; }

/* ---------------------------------------------------------------- toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: center;
  margin: 14px 0;
}

button {
  font: inherit;
  cursor: pointer;
  color: #eee;
  background: var(--button);
  border: 1px solid var(--button-line);
  padding: 8px 16px;
  border-radius: 4px;
}

button:hover { background: var(--button-hover); }
button.primary { background: var(--primary); border-color: var(--primary-line); }
button:focus-visible, a:focus-visible { outline: 3px solid #c9c482; outline-offset: 3px; }
button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary-line); }

.toolbar input[type="range"] { width: 130px; }
.toolbar output { min-width: 3.2em; color: var(--accent); font-variant-numeric: tabular-nums; }
.toolbar .original { margin-left: auto; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.help { border-top: 1px solid var(--line); margin-top: 26px; padding-top: 12px; }
.help h2 { font-size: 1.2rem; }
.help p { color: var(--dim); font-size: .95rem; }

footer { margin-top: 30px; color: #93968b; font-size: .85rem; }

/* -------------------------------------------------------- touch controls */
.touch-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: max(10px, env(safe-area-inset-bottom)) 12px 10px;
  pointer-events: none;
}

.touch-controls .group { display: flex; gap: 10px; }

.touch-controls button {
  pointer-events: auto;
  min-width: 64px;
  min-height: 54px;
  padding: 8px 14px;
  font-size: 1.05rem;
  background: rgba(28, 30, 24, .62);
  border-color: rgba(220, 214, 160, .55);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.touch-controls button.held { background: rgba(120, 128, 88, .8); }

/* ------------------------------------------------------- fullscreen view */
.stage:fullscreen {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: #000;
}

.stage:fullscreen .screen {
  width: auto;
  height: 100%;
  max-width: 100%;
  aspect-ratio: 4 / 3;
}

/* -------------------------------------------------------------- embed mode */
html.embed .shell {
  max-width: none;
  margin: 0;
  padding: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

html.embed .masthead,
html.embed .help,
html.embed footer { display: none; }

html.embed .stage {
  flex: 1;
  min-height: 0;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

html.embed .screen {
  width: 100%;
  max-height: 100%;
  aspect-ratio: 4 / 3;
}

html.embed .toolbar {
  flex: none;
  margin: 0;
  padding: 6px 10px;
  gap: 8px;
  background: #101110;
  border-top: 1px solid var(--line);
  flex-wrap: nowrap;
  overflow-x: auto;
}

html.embed .embed-hide { display: none; }

html.embed .toolbar button { padding: 6px 10px; }
html.embed .toolbar input[type="range"] { width: 80px; }
html.embed #volume-value { display: none; }
html.embed .toolbar .original { font-size: .85rem; }
html.embed .panel { padding: 14px; }
html.embed .panel p { font-size: .9rem; }

@media (max-width: 620px) {
  .shell { padding: 18px 12px 30px; }
  .toolbar { gap: 8px; }
  .toolbar button { padding: 7px 11px; }
  .toolbar .original { margin-left: 0; }
  .touch-controls button { min-width: 58px; min-height: 50px; }
}
