/* ════════════════════════════════════════════════════
   DESIGN TOKENS
   ════════════════════════════════════════════════════ */
:root {
  --fg:      #FCEE0A;   /* yellow  — primary text & borders */
  --fg-dim:  #5a5200;   /* dim yellow — CURRENT score in calc  */
  --g:       #00FF00;   /* neon green  — + symbol, confirm     */
  --r:       #FF0000;   /* red         — − symbol, cancel      */
  --c:       #00FFFF;   /* cyan/blue   — entered value in calc  */
  --bg:      #000000;   /* black       — background             */
  --font:    'Orbitron', 'Courier New', monospace;
}

/* ════════════════════════════════════════════════════
   RESET & BASE
   ════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html {
  height: 100%;
  /* Prevent rubber-band scroll on iOS */
  overscroll-behavior: none;
}

body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  text-transform: uppercase;
  overflow: hidden;
  overscroll-behavior: none;
}

button {
  cursor: pointer;
  font-family: var(--font);
  text-transform: uppercase;
  border-radius: 0;       /* hard corners everywhere */
}

.hidden {
  display: none !important;
}

/* ════════════════════════════════════════════════════
   MAIN SCREEN  —  two stacked player halves
   ════════════════════════════════════════════════════ */
#main-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;         /* dynamic viewport height on modern browsers */
  /* Safe-area padding for notched phones */
  padding-top:    env(safe-area-inset-top,    0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow: hidden;
}

/* Thick yellow divider between the two halves */
.divider {
  height: 4px;
  background: var(--fg);
  flex-shrink: 0;
}

/* Each player occupies exactly half the screen */
.player-half {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Player 2's half is flipped 180° so they can read it from the other side */
#p2-half {
  transform: rotate(180deg);
}

/* ── Header strip (nearest the center divider for both players) ── */
.half-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 50px 6px 14px;
  border-bottom: none;
  flex-shrink: 0;
  gap: 8px;
}

/* Diagonal-end decoration on the header right side */
.half-header::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 36px 36px 0;
  border-color: transparent var(--fg) transparent transparent;
}

.label-cred {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--fg);
  flex-shrink: 0;
}

/* Opponent score badge + RIVAL label */
.opp-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.opp-badge {
  border: 1px solid var(--fg);
  color: var(--c);
  font-size: 14px;
  font-weight: 900;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 1px;
}

.opp-label {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--c);
  text-align: center;
  width: 36px;
}

/* ── Body: buttons on the left, large score on the right ── */
.half-body {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  padding: 10px 14px 10px 12px;
  gap: 12px;
}

/* Stacked +/- button column */
.btn-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

/* +/- action buttons */
.act-btn {
  width: 54px;
  height: 54px;
  background: var(--bg);
  border: 2px solid var(--fg);
  font-size: 30px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 80ms;
  touch-action: manipulation;
}

.act-btn:active {
  background: #1c1800;
}

.act-btn.plus  { color: var(--g); }
.act-btn.minus { color: var(--r); }

/* Quick +1 / −1 buttons — visual separation from main pair */
.act-btn.quick {
  margin-top: 4px;
}

/* Large clickable score number */
.score-num {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--fg);
  font-size: clamp(72px, 23vw, 116px);
  font-weight: 900;
  text-align: right;
  line-height: 1;
  padding: 0 6px;
  letter-spacing: -2px;
  /* Subtle right-side border accent */
  border-right: 3px solid var(--fg);
  outline: none;
}

.score-num:active {
  color: var(--r);
}

/* Footer bar: share button + made-by credit — bottom-right of P1 half */
.footer-bar {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.share-btn {
  background: var(--bg);
  border: 1px solid var(--fg);
  color: var(--fg);
  padding: 5px 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.share-btn:active {
  background: #1c1800;
}

.made-by {
  border: 1px solid var(--fg);
  color: var(--c);
  font-family: var(--font);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-decoration: none;
  padding: 0 9px;
  display: flex;
  align-items: center;
}

.made-by:active {
  background: #1c1800;
}

/* Corner cut decoration — bottom-left of each half-body */
.half-body::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 28px 0 0 28px;
  border-color: transparent transparent transparent var(--fg);
}

/* ════════════════════════════════════════════════════
   CALCULATOR SCREEN
   ════════════════════════════════════════════════════ */
#calc-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  /* Safe-area padding */
  padding-top:    env(safe-area-inset-top,    0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left:   env(safe-area-inset-left,   0px);
  padding-right:  env(safe-area-inset-right,  0px);
  z-index: 50;
}

/* Rotate the whole overlay 180° for Player 2 */
#calc-screen.rotated {
  transform: rotate(180deg);
}

/* ── Top section: CURRENT / NEW scores ── */
.calc-scores {
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  padding: 16px 20px 12px;
  flex-shrink: 0;
}

.calc-score-block {
  text-align: center;
}

.calc-lbl {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--fg);
  margin-bottom: 4px;
}

/* CURRENT score — dimmed yellow */
.calc-curr {
  font-size: clamp(52px, 18vw, 80px);
  font-weight: 900;
  line-height: 1;
  color: var(--fg-dim);
  letter-spacing: -2px;
}

/* NEW score — bright yellow */
.calc-new {
  font-size: clamp(52px, 18vw, 80px);
  font-weight: 900;
  line-height: 1;
  color: var(--fg);
  letter-spacing: -2px;
}

/* Separator line */
.calc-sep {
  height: 2px;
  background: var(--fg);
  flex-shrink: 0;
}

/* ── Operation row: + 99 ── */
.calc-op-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px 20px 10px;
  flex-shrink: 0;
  border-bottom: 2px solid var(--fg);
}

.calc-op-sign {
  font-size: clamp(26px, 8vw, 38px);
  font-weight: 900;
  color: var(--fg);
}

.calc-op-val {
  font-size: clamp(30px, 10vw, 48px);
  font-weight: 900;
  color: var(--c);     /* cyan */
  min-width: 2.2ch;
  text-align: left;
  letter-spacing: -1px;
}

/* ── Numpad: 4×4 grid ── */
.numpad {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 5px;
  padding: 6px;
}

/* Base numpad key */
.nk {
  background: var(--bg);
  border: 2px solid var(--fg);
  color: var(--fg);
  font-size: clamp(20px, 6vw, 30px);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 80ms;
}

.nk:active {
  background: #1c1800;
}

/* Cancel button — red */
.nk-cancel {
  color: var(--r);
  border-color: var(--r);
  font-size: clamp(18px, 5.5vw, 26px);
}

.nk-cancel:active {
  background: #1a0000;
}

/* Confirm button — green */
.nk-confirm {
  color: var(--g);
  border-color: var(--g);
  font-size: clamp(18px, 5.5vw, 26px);
}

.nk-confirm:active {
  background: #001a00;
}

/* Zero spans 2 columns */
.nk-zero {
  grid-column: span 2;
}

/* Backspace */
.nk-back {
  font-size: clamp(16px, 5vw, 24px);
}

/* ════════════════════════════════════════════════════
   RESET CONFIRMATION MODAL
   ════════════════════════════════════════════════════ */
#reset-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-box {
  background: var(--bg);
  border: 2px solid var(--fg);
  padding: 28px 24px 22px;
  min-width: 260px;
  max-width: 88vw;
  position: relative;
}

.modal-box::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 22px 22px 0;
  border-color: transparent var(--fg) transparent transparent;
}

/* Rotate modal box for Player 2 so they can read it */
#reset-modal.rotated .modal-box {
  transform: rotate(180deg);
}

.modal-title {
  color: var(--fg);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 2px;
  text-align: center;
  margin-bottom: 22px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.modal-btn {
  padding: 12px 22px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  border: 2px solid;
  transition: background 80ms;
}

.modal-cancel {
  background: var(--bg);
  border-color: var(--fg);
  color: var(--fg);
}

.modal-cancel:active {
  background: #1c1800;
}

.modal-ok {
  background: var(--r);
  border-color: var(--r);
  color: var(--bg);
}

.modal-ok:active {
  background: #cc0000;
}

/* ════════════════════════════════════════════════════
   QR CODE SHARE MODAL
   ════════════════════════════════════════════════════ */
#qr-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 110;
}

.qr-box {
  background: var(--bg);
  border: 2px solid var(--fg);
  padding: 24px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  position: relative;
}

.qr-box::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 22px 22px 0;
  border-color: transparent var(--fg) transparent transparent;
}

.qr-title {
  color: var(--fg);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 3px;
}

#qr-code canvas,
#qr-code img {
  display: block;
}

.qr-close {
  background: var(--bg);
  border: 2px solid var(--fg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 10px 24px;
  text-transform: uppercase;
  transition: background 80ms;
}

.qr-close:active {
  background: #1c1800;
}
