:root {
  --bench: #1a1915;
  --card: #e9e1c8;
  --card-edge: #c9bc95;
  --ink: #23272b;
  --grease: #a8261c;
  --enamel: #66745f;
  --amber: #f0a637;
  --type: "Courier New", Courier, monospace;
  --sans: "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--bench); color: var(--ink);
  font-family: var(--sans); overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
body {
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255,240,200,0.06), transparent 70%),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.015) 0 2px, transparent 2px 7px),
    var(--bench);
}
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }
.card-screen { align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }

.logcard {
  position: relative; width: 100%; max-width: 420px; background: var(--card);
  border-radius: 4px; padding: 22px 20px 20px; font-family: var(--type);
  box-shadow: 0 10px 40px rgba(0,0,0,0.6), inset 0 0 60px rgba(140,110,50,0.25);
  background-image:
    repeating-linear-gradient(0deg, transparent 0 27px, rgba(60,90,130,0.18) 27px 28px),
    radial-gradient(circle at 80% 10%, rgba(140,100,40,0.15), transparent 40%);
}
.logcard h1 { font-family: var(--sans); letter-spacing: 6px; font-size: 40px; margin: 6px 0 0; }
.logcard h2 { font-family: var(--sans); letter-spacing: 2px; font-size: 22px; margin: 6px 0 12px; text-transform: uppercase; }
.sub { margin: 2px 0 18px; font-size: 13px; }
.stamp {
  position: absolute; right: 14px; top: 14px; color: var(--grease); border: 2px solid var(--grease);
  padding: 2px 6px; font: 700 11px var(--sans); letter-spacing: 2px; transform: rotate(6deg); opacity: 0.75;
}
label { display: block; font-size: 14px; margin: 10px 0; font-weight: 700; }
.hint { font-weight: 400; opacity: 0.7; }
input {
  display: block; width: 100%; margin-top: 4px; font: 700 30px var(--type); letter-spacing: 10px;
  text-transform: uppercase; padding: 8px 10px; background: rgba(255,255,255,0.45);
  border: 0; border-bottom: 2px solid var(--ink); color: var(--ink); border-radius: 0;
  -webkit-user-select: text; user-select: text;
}
input:focus { outline: 2px solid var(--amber); }
.btn {
  display: block; width: 100%; margin: 10px 0 0; padding: 14px; font: 700 17px var(--sans);
  letter-spacing: 1px; text-transform: uppercase; border: 2px solid var(--ink); border-radius: 3px;
  background: transparent; color: var(--ink); cursor: pointer;
}
.btn.primary { background: var(--ink); color: var(--card); }
.btn.ghost { border-style: dashed; font-size: 14px; }
.btn.small { font-size: 13px; padding: 10px 6px; margin: 0; }
.btn:active { transform: translateY(1px); }
.btn.mode { text-align: left; text-transform: none; padding: 12px 14px; }
.btn.mode b { display: block; font-size: 19px; letter-spacing: 1px; text-transform: uppercase; }
.btn.mode span { display: block; font: 400 13px var(--type); margin-top: 3px; }
.row { display: flex; gap: 8px; margin-top: 14px; }
.row > * { flex: 1; }
.err { color: var(--grease); min-height: 1.2em; font-weight: 700; }
.who { font-size: 13px; opacity: 0.8; }
.duelnote { margin-top: 12px; font-size: 13px; border-left: 3px solid var(--grease); padding-left: 8px; }
.best { font-size: 13px; margin: 10px 0 0; }

/* Play */
#hud {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  padding-top: max(6px, env(safe-area-inset-top)); background: #0e0e0c; color: #e9e1c8;
  font-family: var(--type); border-bottom: 1px solid #333; min-height: 46px;
}
#hudMain { flex: 1; display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
#hudMode { font: 700 14px var(--sans); letter-spacing: 2px; color: var(--amber); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hudInfo { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hudRight { display: flex; align-items: center; gap: 8px; }
#hudTime { font: 700 20px var(--type); min-width: 72px; text-align: right; }
.hudbtn {
  background: transparent; color: #e9e1c8; border: 1px solid #666; border-radius: 3px;
  font: 700 14px var(--sans); padding: 6px 10px; letter-spacing: 1px;
}
#stage { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; }
#panel { touch-action: none; display: block; }

.toast {
  position: fixed; left: 50%; top: 64px; transform: translateX(-50%) rotate(-1deg); width: min(92vw, 380px);
  background: var(--card); color: var(--ink); font-family: var(--type); padding: 10px 14px;
  border-left: 6px solid var(--grease); box-shadow: 0 6px 24px rgba(0,0,0,0.6); font-size: 15px;
  pointer-events: none; z-index: 5; transition: opacity 0.3s;
}
.toast b { font-family: var(--sans); letter-spacing: 1px; text-transform: uppercase; display: block; font-size: 17px; }
.toast.good { border-left-color: #2d7a3a; }
.infocard {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(94vw, 400px);
  background: var(--card); font-family: var(--type); padding: 12px 14px; font-size: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.6); z-index: 5; pointer-events: none; border-top: 4px solid var(--ink);
}
.infocard b { display: block; font: 700 16px var(--sans); letter-spacing: 1px; margin-bottom: 4px; }
.countdown {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  font: 700 120px var(--sans); color: var(--amber); text-shadow: 0 0 30px rgba(0,0,0,0.9);
  pointer-events: none; z-index: 6;
}

.overlay {
  position: fixed; inset: 0; background: rgba(10,10,8,0.82); display: flex; align-items: center;
  justify-content: center; padding: 14px; z-index: 10;
}
.sheet {
  width: 100%; max-width: 420px; max-height: 100%; overflow-y: auto; background: var(--card);
  padding: 16px; font-family: var(--type); border-radius: 4px; box-shadow: 0 10px 40px rgba(0,0,0,0.7);
}
.sheet h2 { font-family: var(--sans); letter-spacing: 2px; margin: 4px 0 10px; text-transform: uppercase; }
.sheet .big { font: 700 44px var(--type); margin: 6px 0; }
.sheet table { width: 100%; border-collapse: collapse; font-size: 14px; }
.sheet td { padding: 3px 0; border-bottom: 1px dotted rgba(0,0,0,0.3); }
.sheet td:last-child { text-align: right; }
.rating { display: inline-block; border: 3px solid currentColor; padding: 4px 10px; font: 700 20px var(--sans);
  letter-spacing: 2px; text-transform: uppercase; transform: rotate(-4deg); margin: 8px 0; }
#aar { width: 100%; display: block; border-radius: 2px; margin-bottom: 8px; }
.skiphint { font-size: 12px; text-align: center; opacity: 0.7; margin: 0; }

.how .howpanes { display: flex; overflow: hidden; }
.how .pane { flex: 0 0 100%; transition: transform 0.3s; font-size: 15px; line-height: 1.4; }
.how h3 { font-family: var(--sans); font-size: 22px; letter-spacing: 2px; margin: 4px 0 8px; text-transform: uppercase; }
.dots { display: flex; justify-content: center; gap: 8px; margin-top: 10px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--ink); }
.dots i.on { background: var(--ink); }
