/* Ensure hidden screens never block clicks */
.screen[hidden]{ display:none !important; pointer-events:none !important; }
.screen{ pointer-events:auto !important; }

@font-face{
  font-family:"JustMeAgainDownHereLocal";
  src:url("/fonts/JustMeAgainDownHere/JustMeAgainDownHere-Regular.ttf") format("truetype");
  font-weight:400;
  font-style:normal;
}
@font-face{
  font-family:"JapaneseES";
  src:url("/fonts/JapaneseES.ttf") format("truetype");
  font-weight:normal;
  font-style:normal;
  font-display:swap;
}

:root{
  --ink:#0f172a;
  --muted:rgba(15,23,42,0.62);
  --green:#7ac143;
  --green-d:#63a230;
  --yellow:#ffe815;
  --panel:rgba(255,255,255,0.92);
  --shadow:0 20px 50px rgba(0,0,0,0.14);
  --radius:28px;
}

html, body{
  height:100%;
  touch-action: manipulation;
}

*{ box-sizing:border-box; }

body{
  margin:0;
  font-family:"Zen Kaku Gothic New", system-ui, -apple-system, sans-serif;
  color:var(--ink);
  background:
	radial-gradient(900px 500px at 20% 15%, rgba(255,255,255,0.65), transparent 60%),
	radial-gradient(900px 500px at 80% 20%, rgba(230,230,230,0.55), transparent 60%),
	radial-gradient(900px 500px at 50% 85%, rgba(210,210,210,0.45), transparent 60%),
	#eef1f5;
  overflow:hidden;
}

/* ===== Header (Sandbox) ===== */
.site-header{
  position:sticky; top:0; z-index:100;
  background:rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  border-bottom:1px solid rgba(0,0,0,0.08);
}
.nav-wrap{
  width:100%;
  padding:12px 28px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.brand{
  display:flex;
  align-items:center;
  gap:10px;
  text-decoration:none;
}
.brand img{ width:42px; height:42px; display:block; }
.brand-title{
  font-family:"JustMeAgainDownHereLocal",cursive;
  font-size:clamp(26px,3.8vw,42px);
  line-height:1;
  color:#000;
}
.nav-links{ display:flex; align-items:center; gap:12px; }
.nav-link{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  text-decoration:none;
  font-weight:700;
  font-size:18px;
  color:#fff;
  background:linear-gradient(180deg,#90e065,#5cb93a);
  border-radius:14px;
  padding:10px 18px;
  box-shadow:0 4px 0 #4e8c32,0 6px 10px rgba(0,0,0,.15);
  transition:transform .1s,box-shadow .2s;
  -webkit-tap-highlight-color: transparent;
}
.nav-link:hover{
  transform:translateY(-2px);
  box-shadow:0 6px 0 #4e8c32,0 10px 14px rgba(0,0,0,.2);
}
.nav-link:active{
  transform:translateY(2px);
  box-shadow:0 2px 0 #4e8c32;
}

/* ===== App layout ===== */
.app{
  height: calc(100% - 72px);
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:12px;
}

.screen{
  flex:1;
  min-height:0;
  display:flex;
  align-items:center;
  justify-content:center;
}

/* ===== Start card ===== */
.cardPanel{
  width:min(980px,94vw);
  background:var(--panel);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:26px;
}
.bigTitle{
  margin:0 0 10px 0;
  font-size:clamp(34px, 4.0vw, 54px);
}
.funTitle{
  font-family:"Mochiy Pop P One", system-ui, sans-serif;
  letter-spacing: 0.02em;
}
.muted{ color:var(--muted); font-weight:800; }
.startText{ font-size:18px; line-height:1.6; }

.formRow{ margin-top:16px; }
.label{ font-weight:900; color:rgba(15,23,42,0.65); margin-bottom:10px; font-size:16px; }

.nameInput{
  width:50%;
  max-width:460px;
  min-width:240px;
  font-size:20px;
  padding:14px 14px;
  border-radius:18px;
  border:2px solid rgba(15,23,42,0.14);
  outline:none;
}
.nameInput:focus{ border-color:rgba(122,193,67,0.55); }

.actions{ display:flex; gap:12px; flex-wrap:wrap; margin-top:16px; }
.goBtn{
  width:min(420px, 100%);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:0;
  border-radius:26px;
  padding:18px 16px;
  min-height:72px;
  font-weight:900;
  font-size:24px;
  cursor:pointer;
  background:linear-gradient(180deg, var(--green), var(--green-d));
  color:white;
  -webkit-tap-highlight-color: transparent;
}
.subBtn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:0;
  border-radius:20px;
  padding:14px 18px;
  min-height:56px;
  font-weight:900;
  font-size:18px;
  cursor:pointer;
  background:rgba(15,23,42,0.08);
  color:var(--ink);
  -webkit-tap-highlight-color: transparent;
  text-decoration:none;
}

/* How panel */
.howPanel{
  margin-top:16px;
  background:rgba(15,23,42,0.05);
  border-radius:18px;
  padding:14px 16px;
}
.howPanel ol{ margin:0 0 0 18px; }
.howPanel li{ margin:8px 0; font-weight:800; font-size:16px; line-height:1.5; }

/* ===== Game layout ===== */
#screenGame{
  justify-content:flex-start;
  width:100%;
  align-items:stretch;
}
.play{
  width:100%;
  flex:1;
  min-height:0;
  display:flex;
  flex-direction:column;
  gap:14px;
}

.panel{
  flex:1;
  min-height:0;
  width:100%;
  background:rgba(255,255,255,0.70);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:16px;
  backdrop-filter: blur(6px);
  display:flex;
}
.bottomPanel{ flex:0.85; }

.arena{
  position:relative;
  flex:1;
  min-height:0;
  width:100%;
  border-radius:20px;
  overflow:hidden;
  background:
	radial-gradient(900px 500px at 50% 10%, rgba(96,165,250,0.10), transparent 60%),
	rgba(15,23,42,0.04);
}

/* Bottom grid 2 rows x 8 */
.arena.bottom-grid{
  display:grid;
  grid-template-columns:repeat(8, minmax(0, 1fr));
  gap:12px;
  padding:12px;
  align-items:center;
  justify-items:center;
}

/* ===== HUD (between panels) ===== */
.hudRow{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:14px;
  flex-wrap:wrap;
  margin: 0;
}
.hudPill{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  background:#fff;
  border:2px solid rgba(15,23,42,0.12);
  border-radius:14px;
  padding:10px 14px;
  font-weight:900;
  box-shadow:0 6px 12px rgba(0,0,0,0.08);
}
.hudRound{
  font-weight:900;
  font-size:18px;
  padding:10px 14px;
  background:#fff;
  border-radius:14px;
  border:2px solid rgba(15,23,42,0.12);
  box-shadow:0 6px 12px rgba(0,0,0,0.08);
}
.hudTime{ min-width:160px; }
.timeIcon{ font-size:14px; opacity:0.7; letter-spacing:0.08em; }

#hudTime{
  display:inline-block;
  width: 8ch; /* stops jitter */
  text-align:right;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-variant-numeric: tabular-nums;
  font-weight:900;
  font-size:20px;
}

.hudHearts{ gap:6px; padding:10px 12px; }
.heart{
  font-size:20px;
  transition: opacity .22s ease;
}
.heart.off{ opacity:0.25; }

.hudBtn{
  cursor:pointer;
  background:rgba(15,23,42,0.08);
  border:none;
  -webkit-tap-highlight-color: transparent;
}

/* ===== Letter cards ===== */
.letter{
  position:absolute;
  border-radius:22px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-family:"JapaneseES","Zen Kaku Gothic New",sans-serif;
  font-size: clamp(28px, 4vw, 52px);
  font-weight:normal;
  background:white;
  border:3px solid rgba(15,23,42,0.10);
  box-shadow:0 10px 18px rgba(0,0,0,0.10);
  cursor:pointer;
  user-select:none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, opacity .12s ease, filter .12s ease;
  transform: rotate(var(--rot));
}
.letter:active{ transform: translateY(1px) rotate(var(--rot)); }

.arena.bottom-grid .letter{
  position:relative !important;
  width: var(--w, 72px);
  height: var(--h, 72px);
  transform: rotate(0deg);
}

/* Lowercase baseline (same for top & bottom; em-based like your first app) */
.letter.is-lower::after{
  content:"";
  position:absolute;
  left:14%;
  right:14%;
  bottom: 0.50em;
  height:2px;
  background:#e11d48;
  border-radius:2px;
  opacity:0.25;
  pointer-events:none;
}

/* Animations */
.spawn{ animation: popIn .26s ease both; }
@keyframes popIn{
  from{ opacity:0; transform: translateY(10px) scale(.92) rotate(var(--rot)); }
  to{ opacity:1; transform: translateY(0) scale(1) rotate(var(--rot)); }
}

.target{
  outline:4px solid rgba(255,232,21,0.85);
  box-shadow:0 0 0 6px rgba(255,232,21,0.30), 0 10px 18px rgba(0,0,0,0.12);
  animation:pulse 900ms ease-in-out infinite;
}
@keyframes pulse{
  0%,100%{ transform: scale(1) rotate(var(--rot)); }
  50%{ transform: scale(1.05) rotate(var(--rot)); }
}

.shake{ animation: shake .22s ease; }
@keyframes shake{
  0%{transform:translateX(0) rotate(var(--rot))}
  25%{transform:translateX(-6px) rotate(var(--rot))}
  50%{transform:translateX(6px) rotate(var(--rot))}
  75%{transform:translateX(-4px) rotate(var(--rot))}
  100%{transform:translateX(0) rotate(var(--rot))}
}

.vanish{ animation: vanish .22s ease forwards; }
@keyframes vanish{
  to{ opacity:0; transform: translateY(-8px) scale(.85) rotate(var(--rot)); }
}

.disabled{
  opacity:0.30;
  pointer-events:none;
  filter:saturate(0.85);
}

/* ===== Countdown overlay ===== */
#countdownOverlay{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  pointer-events:none !important;
  z-index:99999;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: rgba(255,255,255,0.35);
}
#countdownOverlay[hidden]{ display:none !important; }

.countdownBox{
  width: min(520px, 86vw);
  height: min(320px, 44vh);
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius: 26px;
  background: rgba(255,255,255,0.78);
  box-shadow: 0 18px 45px rgba(0,0,0,0.18);
  border: 2px solid rgba(15,23,42,0.10);
}

#countdown{
  font-family:"JapaneseES","Zen Kaku Gothic New",sans-serif;
  font-size: clamp(96px, 14vw, 180px);
  font-weight:normal;
  color: rgba(15,23,42,0.92);
  text-shadow: 0 12px 30px rgba(0,0,0,0.12);
}

/* Toast */
.toast{
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 10px 14px;
  background: rgba(15,23,42,0.88);
  color: white;
  border-radius: 999px;
  font-weight: 900;
  box-shadow: 0 16px 30px rgba(0,0,0,0.18);
  z-index: 9999;
}

/* ===== End screen ===== */
.endCard{
  width:min(860px, 94vw);
  background:var(--panel);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:26px;
  text-align:center;
}

.endTitle{
  font-size:34px;
  margin:0 0 10px 0;
  font-weight: 900;
}

.endInfo{
  display:grid;
  gap:16px;
  justify-items:center;
  padding:18px 20px;
  border-radius:18px;
  background:rgba(15,23,42,0.05);
  max-width:620px;
  margin:14px auto 14px;
  text-align:left;
}
.endInfo > div{
  width:100%;
  display:flex;
  justify-content:space-between;
  gap:18px;
  align-items:center;
}
.endInfo .k{
  font-size:22px;
  line-height:1.2;
  display:flex;
  align-items:center;
  gap:12px;
  color:rgba(15,23,42,0.62);
  font-weight:900;
}
#overName,#overRounds,#overTime,#overLives,#overPoints{
  font-size:24px;
  font-weight:900;
  font-family:"Zen Kaku Gothic New", system-ui, -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
}

.endStamp{
  justify-content:center !important;
}
.endStamp span{
  font-size:20px;
  font-weight:900;
  font-family:"Zen Kaku Gothic New", system-ui, -apple-system, sans-serif;
  opacity:0.75;
  white-space:nowrap;
}

/* ===== Confetti (Finished only) ===== */
.confetti{
  position:fixed;
  inset:0;
  pointer-events:none;
  overflow:hidden;
  z-index:999999;
}
.confetti[hidden]{ display:none !important; }

.confetti-piece{
  position:absolute;
  top:-12px;
  width:10px;
  height:14px;
  border-radius:3px;
  opacity:0.95;
  transform:translateY(-20px) rotate(0deg);
  animation:confettiFall var(--dur, 1400ms) ease-out forwards;
  animation-delay:var(--delay, 0ms);
}

@keyframes confettiFall{
  0%   { transform:translate3d(var(--x,0), -20px, 0) rotate(0deg); opacity:0; }
  10%  { opacity:1; }
  100% { transform:translate3d(var(--x,0), 110vh, 0) rotate(var(--rot, 520deg)); opacity:0; }
}

/* ===== Strong disabled look (bottom cards) ===== */
/* Put this at the END of style.css */

.letter.disabled,
.disabled{
  opacity: 0.22 !important;
  filter: grayscale(1) saturate(0.2) brightness(0.98) !important;
  pointer-events: none !important;
}

/* add a faint overlay so it still looks disabled even if opacity is ignored */
.letter.disabled::before{
  content:"";
  position:absolute;
  inset:0;
  border-radius: inherit;
  background: rgba(15,23,42,0.08);
  pointer-events:none;
}

/* optional: make border a bit more muted */
.letter.disabled{
  border-color: rgba(15,23,42,0.06) !important;
  box-shadow: 0 6px 12px rgba(0,0,0,0.06) !important;
}