/* 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;

  /* IMPORTANT: ensures start UI sits above any stray layers */
  position:relative;
  z-index:10;
}
.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); }

.tinyNote{
  margin-top:8px;
  font-size:12px;
  color:rgba(15,23,42,0.55);
  font-weight:800;
}

.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; }

/* ===== Mode buttons ===== */
.modeRow{
  margin-top:14px;
  display:flex;
  gap:12px;
  flex-wrap:wrap;
}
.modeBtn{
  border:0;
  border-radius:18px;
  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;
}
.modeBtn.isActive{
  background:linear-gradient(180deg, var(--green), var(--green-d));
  color:#fff;
}

/* ===== 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;
}

/* Single arena panel */
.singlePanel{ flex:1; }

/* ===== Arena base ===== */
.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);
}

/* Grid arena for Simon */
.arena.gridArena{
  display:grid;
  gap:12px;
  padding:12px;
  align-items:center;
  justify-items:center;
}

/* ===== HUD ===== */
.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);
}
.hudHearts{ gap:6px; padding:10px 12px; }
.heart{
  font-size:20px;
  transition: opacity .22s ease;
}
.heart.off{ opacity:0.25; }

/* ===== Letter cards ===== */
.letter{
  position:relative; /* IMPORTANT for ::before/::after layers */
  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(0deg);
  width: var(--w, 96px);
  height: var(--h, 96px);
}
.letter:active{ transform: translateY(1px) rotate(0deg); }

/* Lowercase baseline */
.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;
}

/* Target flash */
.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); }
  50%{ transform: scale(1.05); }
}

/* 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;
}

/* ===== Round screen card ===== */
.roundCard{
  width:min(560px, 92vw);
  background:var(--panel);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:26px;
  text-align:center;
}
.roundWord{
  font-weight:900;
  font-size:20px;
  color:rgba(15,23,42,0.55);
  letter-spacing:0.08em;
}
.roundNum{
  font-family:"JapaneseES","Zen Kaku Gothic New",sans-serif;
  font-weight:normal;
  font-size: clamp(96px, 14vw, 180px);
  line-height:1;
  margin:10px 0 8px;
}
.roundHint{
   font-size: clamp(120px, 18vw, 220px);
   line-height: 1;
   margin-top: 6px;
 }

/* ===== 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,#overLives{
  font-size:24px;
  font-weight:900;
  font-family:"Zen Kaku Gothic New", system-ui, -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
}

/* ===== Strong disabled look (ONLY for letter buttons) ===== */
.letter.disabled{
  opacity: 0.22 !important;
  filter: grayscale(1) saturate(0.2) brightness(0.98) !important;
  pointer-events: none !important;
}
.letter.disabled::before{
  content:"";
  position:absolute;
  inset:0;
  border-radius: inherit;
  background: rgba(15,23,42,0.08);
  pointer-events:none;
}
.letter.disabled{
  border-color: rgba(15,23,42,0.06) !important;
  box-shadow: 0 6px 12px rgba(0,0,0,0.06) !important;
}

/* Correct = fade away */
.vanish{
  animation: vanish .22s ease forwards;
}
@keyframes vanish{
  to{
    opacity:0;
    transform: scale(.92);
    filter: blur(0.4px);
  }
}

/* Wrong = jiggle */
.shake{ animation: shake .22s ease; }
@keyframes shake{
  0%{transform:translateX(0)}
  25%{transform:translateX(-6px)}
  50%{transform:translateX(6px)}
  75%{transform:translateX(-4px)}
  100%{transform:translateX(0)}
}

/* === ROUND overlay: note only (no white card) === */
/* === Listening overlay: VOICE icon only === */
.roundCard{
  background: transparent !important;
  box-shadow: none !important;
  border: 0 !important;
  padding: 0 !important;
  width: auto !important;
}

/* hide unused round labels */
.roundWord,
.roundNum{
  display: none !important;
}

/* big pulsing voice icon */
.roundHint{
  font-size: clamp(120px, 20vw, 240px);
  line-height: 1;
  margin: 0;
  animation: voicePulse 1.2s ease-in-out infinite;
  filter: drop-shadow(0 18px 40px rgba(0,0,0,0.12));
}

/* gentle pulse = listening */
@keyframes voicePulse{
  0%,100%{
    transform: scale(1);
    opacity: 0.85;
  }
  50%{
    transform: scale(1.08);
    opacity: 1;
  }
}

#screenRound{
  backdrop-filter: blur(6px);
  background: rgba(255,255,255,0.18);
}
