/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-height: 100dvh;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* Pointer-aware copy swap (touch class set by JS) */
.when-touch { display: none; }
body.touch .when-hover { display: none; }
body.touch .when-touch { display: inline; }

/* ── Pixel Hunt ── */

:root {
  --font-mono: 'Courier New', Courier, monospace;
  --color-void: #ffffff;
  --color-ink: #000000;
  --color-pastel: #e8c86a;
  --color-pastel-dark: #9a7b2a;
  --color-scare: #000000;
  --timer-size: clamp(10px, 2vw, 13px);
  --ui-size: clamp(11px, 2.2vw, 14px);
}

body {
  background: var(--color-void);
  color: var(--color-ink);
  font-family: var(--font-mono);
  font-size: var(--ui-size);
  letter-spacing: 0.04em;
}

/* Panel visibility — all hidden by default, shown by body[data-state] */
#panel-idle, #panel-hunt, #panel-jumpscare, #panel-cute, #panel-result { display: none; }
body[data-state="idle"]      #panel-idle      { display: flex; }
body[data-state="hunting"]   #panel-hunt      { display: block; }
body[data-state="jumpscare"] #panel-jumpscare { display: flex; }
body[data-state="cute"]      #panel-cute      { display: flex; }
body[data-state="result"]    #panel-result    { display: flex; }

body[data-state="hunting"] { cursor: crosshair; }

/* Idle panel */
#panel-idle {
  padding: 48px 32px;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
}
#idle-label { font-size: var(--ui-size); opacity: 0.5; }
#idle-label-2 { font-size: clamp(18px, 5vw, 28px); font-weight: normal; letter-spacing: -0.01em; }
#btn-start {
  margin-top: 32px;
  background: none; border: 1px solid var(--color-ink);
  font-family: var(--font-mono); font-size: var(--ui-size);
  padding: 10px 18px; cursor: pointer; letter-spacing: 0.08em;
  width: fit-content; min-height: 44px;
  touch-action: manipulation;
}
#btn-start:hover { background: var(--color-ink); color: var(--color-void); }

/* Hunt panel */
#panel-hunt {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
#timer {
  position: absolute;
  top: 16px; left: 16px;
  font-family: var(--font-mono);
  font-size: var(--timer-size);
  opacity: 0.3;
  pointer-events: none;
  letter-spacing: 0.1em;
}

/* The pixel — 1×1 CSS pixel, fully invisible. The "magic" is that you can't see it. */
#pixel {
  position: absolute;
  width: 1px;
  height: 1px;
  background: transparent;
  cursor: pointer;
}
#pixel::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
}
@media (pointer: fine) {
  #pixel::before { width: 8px; height: 8px; }
}

/* Mercy hint */
#mercy-hint {
  position: absolute;
  bottom: 52px; left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  opacity: 0;
  transition: opacity 1s;
  pointer-events: none;
  white-space: nowrap;
}
#mercy-hint.visible { opacity: 0.35; }

/* Jumpscare panel */
#panel-jumpscare {
  position: fixed; inset: 0; z-index: 100;
  background: var(--color-scare);
  justify-content: center; align-items: center;
  animation: scare-flash 0.08s steps(1) forwards;
  cursor: pointer;
}
@keyframes scare-flash {
  0%   { background: var(--color-void); }
  50%  { background: var(--color-scare); }
  100% { background: var(--color-scare); }
}
#scare-face {
  width: min(70vw, 70vh);
  height: min(70vw, 70vh);
  animation: scare-face-in 0.05s steps(1) 0.04s both;
  opacity: 0;
}
@keyframes scare-face-in { to { opacity: 1; } }
#panel-jumpscare.fading {
  animation: scare-fade-out 0.6s ease forwards;
}
@keyframes scare-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; pointer-events: none; }
}

/* Cute panel */
#panel-cute {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(255,255,255,0.01);
  cursor: pointer;
}
#bloom-origin {
  position: absolute;
  transform: translate(-50%, -50%);
}
#cute-character {
  width: 240px; height: auto;
  animation: bloom-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  transform-origin: center bottom;
  opacity: 0;
}
@keyframes bloom-in {
  0%   { transform: scale(0) rotate(-15deg); opacity: 0; }
  60%  { opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
#panel-cute.fading {
  animation: cute-fade-out 0.8s ease 1.5s forwards;
}
@keyframes cute-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* Result panel */
#panel-result {
  padding: 48px 32px;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 360px;
  margin: 0 auto;
  width: 100%;
  min-height: 100dvh;
  justify-content: flex-start;
}
body[data-state="result"] { overflow-y: auto; }
#result-outcome {
  font-size: clamp(15px, 3.5vw, 20px);
  line-height: 1.4;
}
#result-outcome.outcome-cute { color: var(--color-pastel-dark); }
#result-time {
  font-size: var(--ui-size);
  opacity: 0.45;
  margin-bottom: 8px;
}
#btn-share, #btn-again {
  background: none;
  font-family: var(--font-mono); font-size: var(--ui-size);
  padding: 10px 18px; cursor: pointer; letter-spacing: 0.08em;
  width: fit-content; min-height: 44px;
  touch-action: manipulation;
}
#btn-share { border: 1px solid var(--color-ink); display: flex; align-items: center; }
#btn-share:hover { background: var(--color-ink); color: var(--color-void); }
#btn-again {
  border: none; opacity: 0.4;
  text-decoration: underline; padding-left: 0;
  display: flex; align-items: center;
}
#btn-again:hover { opacity: 1; }

/* Scoreboard — clinical, single dotted hairline */
.scoreboard {
  width: 100%;
  margin-top: 8px;
  padding: 14px 0 0;
  border-top: 1px dotted var(--color-ink);
  text-align: left;
  font-family: var(--font-mono);
}
.scoreboard__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.55;
  padding-bottom: 6px;
}
.scoreboard__status {
  font-size: 9px;
  letter-spacing: 0.16em;
}
.scoreboard__list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  gap: 0;
}
.scoreboard__row,
.scoreboard__empty {
  display: grid;
  grid-template-columns: 1.8rem 1fr 3.6rem;
  gap: 8px;
  align-items: baseline;
  font-size: 12px;
  letter-spacing: 0.08em;
  padding: 4px 0;
  border-bottom: 1px dotted rgba(0,0,0,0.12);
}
.scoreboard__row span:first-child { opacity: 0.4; font-size: 10px; }
.scoreboard__row span:last-child { text-align: right; }
.scoreboard__row.is-current {
  color: var(--color-pastel-dark);
  font-weight: bold;
}
.scoreboard__empty {
  grid-template-columns: 1fr;
  text-align: center;
  opacity: 0.35;
  border-bottom: none;
  font-style: italic;
}
.initials-form {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dotted rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.initials-form[hidden] { display: none; }
.initials-form label {
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.55;
  text-align: center;
}
.initials-form__row {
  display: flex;
  gap: 6px;
}
.initials-form input {
  flex: 1;
  background: var(--color-void);
  border: 1px solid var(--color-ink);
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: 16px;
  letter-spacing: 0.3em;
  text-align: center;
  text-transform: uppercase;
  color: var(--color-ink);
  min-width: 0;
}
.initials-form input:focus { outline: none; background: #f6f6f6; }
.initials-form__save {
  background: none;
  border: 1px solid var(--color-ink);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 12px;
  cursor: pointer;
  letter-spacing: 0.1em;
  min-height: 0;
}
.initials-form__save:hover { background: var(--color-ink); color: var(--color-void); }
.initials-form__skip {
  align-self: center;
  background: none;
  border: none;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-decoration: underline;
  opacity: 0.55;
  cursor: pointer;
  min-height: 0;
}
.initials-form__skip:hover { background: none; opacity: 1; }

/* Content warning */
#content-warning {
  position: fixed;
  bottom: 14px; left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  opacity: 0.2;
  pointer-events: none;
  white-space: nowrap;
  z-index: 200;
}
body[data-state="jumpscare"] #content-warning,
body[data-state="cute"]      #content-warning { display: none; }

/* Continue hint on jumpscare/cute panels */
.continue-hint {
  position: absolute;
  bottom: 40px; left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  opacity: 0;
  animation: hint-fade-in 0.4s ease 1.2s forwards;
  pointer-events: none;
  white-space: nowrap;
}
#panel-jumpscare .continue-hint { color: rgba(255,255,255,0.4); }
#panel-cute .continue-hint { color: rgba(0,0,0,0.3); }
@keyframes hint-fade-in {
  to { opacity: 1; }
}
