:root {
  --page-bg: #ffffff;
  --text: #111;
  --pulseRGBA: rgba(77, 163, 255, 0.28);
  --nextOrange: #ff8a1f;
  --nextPulseRGBA: rgba(255, 138, 31, 0.35);
  
  --rushingColor: #4da3ff;
  --onTimeColor: #34c759;
  --draggingColor: #ff8a1f;

  --text-max: 1000px;
  --analysis-max: 700px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--page-bg);
  color: var(--text);
}

.app {
  max-width: 1260px;
  margin: 8px auto;
  padding: 16px;
}

.hero { text-align: center; margin: 0px 0 12px; }

.app-titleWrap {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 14px 0 6px;
}

.app-titleImgmain {
  height: 100%;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  padding-bottom: 10px;
  max-width: 100%;
}

.app-titleImg {
  height: 160px;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  padding-bottom: 2px;
  max-width: 100%;
}
.app-titleImgWide { width: min(400px, 100%); }

.controlsPanel {
  background: #fff;
  border: 1px solid rgba(0,0,0,0);
  border-radius: 16px;
  padding: 0px;
}
.controlsPanelActions { margin-top: 8px; }

.hidden { display: none !important; }

select {
  height: 38px;
  width: auto;
  padding: 0 10px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.2);
  background: #fff;
  cursor: pointer;
  font-weight: 700;
  text-align: center;
}
.compactSelectAuto { width: auto; max-width: none; inline-size: auto; justify-content: center; }

button {
  height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.2);
  background: #fff;
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
  transition: transform 0.1s, opacity 0.2s, background 0.2s;
}
button:active { transform: translateY(1px); }

button:disabled {
  opacity: 0.65 !important;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
  animation: none !important;
}

.primary { background: rgb(71, 101, 166); color: #fff; border-color: rgba(0,0,0,.2); }
#beginBtn.isRestart { background: #fff; color: var(--text); border-color: rgba(0,0,0,.2); }

@keyframes beginPulse {
  0%   { box-shadow: 0 0 0 0 rgba(0,0,0,0); }
  55%  { box-shadow: 0 0 0 12px var(--pulseRGBA); }
  100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); }
}
.pulse:not(:disabled) { animation: beginPulse 1.25s ease-in-out infinite; }

@keyframes nextPulse {
  0%   { box-shadow: 0 0 0 0 rgba(0,0,0,0); }
  55%  { box-shadow: 0 0 0 12px var(--nextPulseRGBA); }
  100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); }
}
.nextReady:not(:disabled) {
  background: var(--nextOrange) !important;
  color: #fff !important;
  border-color: rgba(0,0,0,.15) !important;
  animation: nextPulse 1.05s ease-in-out infinite;
}

.actionsRow { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.actionsCentered { justify-content: center; }

.inlineControl { display: flex; flex-direction: column; gap: 6px; }

/* Answer Stage & Buttons */
.stage {
  max-width: var(--text-max);
  margin: 10px auto 18px;
  background: #fff;
  border-radius: 16px;
  padding: 0px;
}

.answerGrid {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.ansBtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 90px;
  width: 140px;
  border-radius: 16px;
  color: white;
  border: 2px solid rgba(0,0,0,0.1);
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.ansBtn .ansTitle { font-size: 18px; font-weight: 900; margin-bottom: 4px; }
.ansBtn .ansSub { font-size: 11px; font-weight: 700; opacity: 0.9; }

.btn-rushing { background: var(--rushingColor); }
.btn-ontime { background: var(--onTimeColor); }
.btn-dragging { background: var(--draggingColor); }

.ansBtn:not(:disabled):hover { filter: brightness(1.1); }
.ansBtn.correct { background: #1f9d55 !important; transform: scale(1.05); border-color: #116b38; box-shadow: 0 0 15px rgba(31,157,85,0.6); }
.ansBtn.incorrect { background: #d13b3b !important; opacity: 1 !important; }
.ansBtn.faded { opacity: 0.4 !important; filter: grayscale(50%); }

.levelIndicator {
  text-align: center;
  font-weight: 900;
  font-size: 18px;
  color: #444;
  margin: 10px 0 4px;
}

.levelDetailText {
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  opacity: 0.8;
  margin-bottom: 16px;
}

/* Analysis / Scorecard */
.analysis { align-items: center; max-width: var(--analysis-max); margin: 10px auto 0; }
.analysisGrid { display: grid; gap: 10px; margin: 0 auto; }
.oneCol { grid-template-columns: 1fr; }

.analysisCard {
  border: 1px solid rgba(0,0,0,.2);
  border-radius: 14px;
  padding: 12px;
  background: #f9f9f9;
}
.analysisLabel { font-size: 16px; opacity: .85; margin-bottom: 8px; font-weight: 900; text-align: center; }

.scoreCardNarrow { padding: 14px 10px; margin: 0 auto; width: 100%; max-width: 440px; }
.scoreGrid { display: grid; gap: 8px 10px; }
.scoreGridVertical { grid-template-columns: 1fr; gap: 8px; max-width: 420px; margin: 0 auto; }
.scoreItem {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 8px 10px; border: 1px solid rgba(0,0,0,.2); border-radius: 12px; background: #fff;
}
.scoreK { font-size: 12px; opacity: .75; font-weight: 800; }
.scoreV { font-weight: 900; font-variant-numeric: tabular-nums; }
.scoreActions { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.scoreFooter { text-align: center; font-size: 12px; font-weight: 800; opacity: 0.55; margin-top: 24px; }

#playerNameInput, #modalPlayerNameInput { height: 38px; padding: 0 10px; border-radius: 12px; border: 1px solid rgba(0,0,0,.2); font-weight: 800; width: min(240px, 70vw); }

.feedbackLine { max-width: var(--text-max); margin: 16px auto 4px; text-align: center; font-size: 16px; font-weight: 600; line-height: 1.4; opacity: .92; }

/* Modals */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 60px; padding-left: 10px; padding-right: 10px;
  z-index: 50; overflow: auto;
}
.modalCard {
  width: min(720px, 100%); background: white; border-radius: 18px;
  padding: 18px; box-shadow: 0 12px 30px rgba(0,0,0,.25);
  max-height: calc(100dvh - 36px); overflow: auto;
  display: flex; flex-direction: column; align-items: center;
}
.modalTitle { font-size: 18px; font-weight: 900; margin: 0 0 8px; text-align: center; }
.modalBody { font-size: 14px; line-height: 1.45; opacity: .95; text-align: center; width: 100%; }
.modalBody p { margin: 0 0 10px; }
.modalActions { margin-top: 10px; display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.settingsLabel { font-weight: 900; opacity: .78; font-size: 13px; text-align: center; }

@media (max-width: 420px) { button { padding: 0 12px; } }