:root {
  --bg: #111111;
  --surface: #1a1a1a;
  --surface-2: #232323;
  --crimson: #8f1d2c;
  --action: #d83d50;
  --text: #f3e9e5;
  --muted: #b9aca6;
  --gold: #c9a36b;
  --line: #3a2a2d;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 70% at 50% -10%, #2a0f15 0%, var(--bg) 60%) fixed;
  color: var(--text);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
#app {
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(20px + var(--safe-t)) 16px calc(20px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
h1, h2, .display { font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif; font-weight: 600; letter-spacing: .02em; margin: 0; }
h1 { font-size: 2.6rem; line-height: 1.05; color: var(--action); }
h2 { font-size: 1.6rem; color: var(--text); }
p { margin: 0; }
.muted { color: var(--muted); font-size: .95rem; }
.small { font-size: .875rem; }
.center { text-align: center; }
.grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.spacer { flex: 1; }

.brand { text-align: center; padding-top: 6vh; }
.brand .tag { letter-spacing: .3em; font-size: .75rem; color: var(--gold); margin-top: 8px; }

button, select, input {
  font: inherit; color: inherit;
}
.btn {
  min-height: 54px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  touch-action: manipulation;
}
.btn:active { transform: scale(.98); }
.btn:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn.primary { background: var(--action); border-color: var(--action); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { background: #3a0c12; border-color: var(--action); color: #ffd9de; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .9rem; color: var(--muted); }
input[type=text], select {
  min-height: 50px; padding: 10px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); width: 100%;
}

.seg { display: grid; gap: 8px; }
.seg.c2 { grid-template-columns: 1fr 1fr; }
.seg.c3 { grid-template-columns: repeat(3, 1fr); }
.seg.c4 { grid-template-columns: repeat(2, 1fr); }
.seg button {
  min-height: 48px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer; padding: 8px;
}
.seg button[aria-pressed=true] { background: var(--crimson); border-color: var(--action); font-weight: 700; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.notice { border-left: 3px solid var(--gold); background: #1d1a16; padding: 12px 14px; border-radius: 8px; color: #e8dccb; font-size: .95rem; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.player { font-family: Georgia, serif; font-size: 1.25rem; color: var(--gold); }
.lvl { font-size: .85rem; color: var(--muted); text-align: right; }
.bar { height: 8px; border-radius: 8px; background: #2a2024; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--crimson), var(--action)); }

.card {
  background: linear-gradient(160deg, #2a1318, #1a1214 70%);
  border: 1px solid var(--crimson);
  border-radius: 20px;
  padding: 22px 20px;
  min-height: 240px;
  display: flex; flex-direction: column; gap: 14px; justify-content: center;
}
.card .kind { font-size: .8rem; letter-spacing: .25em; color: var(--gold); text-transform: uppercase; }
.card .prompt { font-family: Georgia, serif; font-size: 1.35rem; line-height: 1.45; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 6px 12px; border-radius: 999px; background: #3a1c22; border: 1px solid var(--crimson); font-size: .95rem; }
.timer { font-size: 2.4rem; font-family: Georgia, serif; text-align: center; color: var(--action); }

.actions { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 10px; }
.footer { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: auto; }
.merah { background: #b3182c; border-color: #ff6b7d; color: #fff; font-weight: 800; letter-spacing: .08em; }

.bgrid { display: flex; flex-direction: column; gap: 10px; }
.brow { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.brow .name { text-transform: capitalize; }

.banner { text-align: center; color: var(--gold); font-size: .95rem; }
.linkbtn { background: none; border: 0; padding: 4px 0; color: var(--gold); font: inherit; text-decoration: underline; cursor: pointer; }
.linkbtn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
#code { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .08em; text-transform: uppercase; }

@media (prefers-reduced-motion: reduce) { .btn:active { transform: none; } }
@media (max-width: 360px) { h1 { font-size: 2.2rem; } .actions { grid-template-columns: 1fr; } }
