/* ============================================================
   Snoopy Tennis - Game & Watch replica
   All internal console sizes are in `em`. The #console element's
   font-size is set by JS proportional to its width, so the entire
   device scales as one unit. 1em = 1% of console width.
   ============================================================ */

:root {
  --lavender:      #a98fc6;
  --lavender-dark: #8f76ad;
  --lavender-lite: #c3aede;
  --gold-hi:       #ddcfa4;
  --gold-lo:       #c4b078;
  --silver-hi:     #e6e7e9;
  --silver-lo:     #b9bbbe;
  --lcd-bg:        #aeb49a;
  --lcd-bg2:       #b9bea6;
  --seg:           #2b2b26;      /* lit LCD segment colour */
  --red-hi:        #e8503f;
  --red-lo:        #b3271b;
  --grey-btn:      #bdb9b1;
  --ink:           #1a1a17;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: #26242b;
  background: radial-gradient(circle at 50% 30%, #34313b 0%, #1b1a20 100%);
  font-family: "Helvetica Neue", Arial, sans-serif;
  color: #eee;
  overflow: hidden;
  overscroll-behavior: none;
}

/* ---------------- Top bar ---------------- */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  z-index: 30;
  background: linear-gradient(#000000aa, #00000000);
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }

.size-controls { display: flex; gap: 6px; }
.size-btn {
  font: 600 12px/1 Arial, sans-serif;
  color: #ddd;
  background: #ffffff1a;
  border: 1px solid #ffffff33;
  border-radius: 6px;
  padding: 7px 10px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.size-btn:hover { background: #ffffff30; }
.size-btn.is-active { background: var(--lavender); color: #fff; border-color: var(--lavender-lite); }

#menu-toggle {
  width: 40px; height: 34px;
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
  align-items: center;
  background: #ffffff1a;
  border: 1px solid #ffffff33;
  border-radius: 6px;
  cursor: pointer;
}
#menu-toggle span { display: block; width: 18px; height: 2px; background: #ddd; border-radius: 2px; }

/* ---------------- Popup menu ---------------- */
#popup-menu {
  position: fixed;
  top: 48px; right: 12px;
  width: 200px;
  background: #2c2a33;
  border: 1px solid #ffffff22;
  border-radius: 10px;
  box-shadow: 0 10px 30px #000a;
  padding: 6px;
  z-index: 40;
  display: none;
  flex-direction: column;
}
#popup-menu.is-open { display: flex; }
.menu-item {
  text-align: left;
  font: 500 14px/1.2 Arial, sans-serif;
  color: #eee;
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 11px 12px;
  cursor: pointer;
}
.menu-item:hover { background: #ffffff14; }

/* ---------------- Stage & console ---------------- */
#stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 8px 8px;
}

#console {
  /* width & font-size are set by JS */
  width: 900px;
  font-size: 9px;              /* fallback; JS overrides */
  aspect-ratio: 1600 / 985;
  border-radius: 7em 7em 6em 6em / 9em 9em 8em 8em;
  background:
    linear-gradient(160deg, var(--lavender-lite) 0%, var(--lavender) 38%, var(--lavender-dark) 100%);
  padding: 2.4em;
  box-shadow:
    0 3em 6em #000a,
    inset 0 0 0 .25em #ffffff30,
    inset 0 -1.2em 2em #00000030;
  user-select: none;
  touch-action: manipulation;
}

.face {
  width: 100%; height: 100%;
  border-radius: 4.5em;
  background:
    repeating-linear-gradient(92deg, #ffffff00 0 .18em, #00000008 .18em .36em),
    linear-gradient(150deg, var(--gold-hi) 0%, #cdbb86 46%, var(--gold-lo) 100%);
  box-shadow: inset 0 0 0 .18em #00000022, inset 0 0 1.6em #7a6a3a44;
  display: grid;
  grid-template-columns: 20% 1fr 20%;
  align-items: stretch;
  padding: 2.2em 2.4em;
  gap: 1.4em;
}

/* ---------- Left column ---------- */
.col-left { display: flex; flex-direction: column; align-items: center; }
.brand {
  display: flex; flex-direction: column; align-items: center;
  margin-top: .5em;
}
.brand-box {
  font: 900 3em/0.92 "Arial Black", Arial, sans-serif;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-align: center;
  border: 0.28em solid var(--ink);
  border-radius: 0.5em;
  padding: 0.28em 0.5em;
  background: #fdfaf0;
}
.brand-nintendo {
  font: 700 1.9em/1 Arial, sans-serif;
  color: var(--ink);
  margin-top: .5em;
  letter-spacing: -.01em;
}
.brand-snoopy {
  width: 8em; height: 8em;
  margin: 1.1em 0 auto;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  /* Snoopy-with-racket mascot, drawn as inline SVG */
  background-image: url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 120'>\
<g fill='none' stroke='%231a1a17' stroke-width='3' stroke-linejoin='round' stroke-linecap='round'>\
<ellipse cx='47' cy='47' rx='24' ry='19' fill='white'/>\
<path d='M25 46 Q18 40 26 34' fill='white'/>\
<ellipse cx='36' cy='44' rx='4.5' ry='6' fill='%231a1a17' stroke='none'/>\
<path d='M60 40 q16 -3 20 6' fill='white'/>\
<path d='M22 30 q6 -12 20 -9 q10 -12 24 -3' fill='%231a1a17'/>\
<path d='M50 64 q-4 18 4 30 l16 0 q6 -14 2 -30' fill='white'/>\
<circle cx='92' cy='74' r='13' fill='white'/>\
<path d='M92 61 v-8 M92 87 v8 M79 74 h-8 M105 74 h8 M83 65 l-6 -6 M101 65 l6 -6 M83 83 l-6 6 M101 83 l6 6' stroke-width='2'/>\
<path d='M64 74 L80 74' stroke-width='4'/>\
</g></svg>");
}
.brand-snoopy::after { content: ""; }

/* ---------- Hardware buttons ---------- */
.hw-btn {
  border: none; cursor: pointer; padding: 0;
  position: relative;
  transition: transform .05s;
}
.hw-btn:active, .hw-btn.is-pressed { transform: translateY(0.18em) scale(0.97); }

.hw-red {
  width: 6.4em; height: 6.4em;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, var(--red-hi) 0%, #d13f30 45%, var(--red-lo) 100%);
  box-shadow: 0 0.5em 0.7em #0006, inset 0 0.2em 0.3em #ffffff55, inset 0 -0.3em 0.5em #00000055;
}
.hw-grey {
  width: 4.6em; height: 2.5em;
  border-radius: 1.4em;
  background: linear-gradient(#d3cfc7, var(--grey-btn) 60%, #a29e96);
  box-shadow: 0 0.35em 0.5em #0005, inset 0 0.2em 0.2em #ffffff70, inset 0 -0.2em 0.3em #00000030;
}
.hw-grey.is-disabled { opacity: .5; cursor: not-allowed; }
.hw-label { font: 700 1.55em/1 Arial, sans-serif; color: var(--ink); text-align: center; }

.col-left .hw-red { margin-top: 1.2em; }
.col-left .hw-label { margin-top: .7em; }

/* ---------- Center column ---------- */
.col-center { display: flex; align-items: center; }
.bezel-silver {
  width: 100%;
  border-radius: 1.6em;
  padding: 1.4em 1.6em;
  background: linear-gradient(150deg, var(--silver-hi) 0%, #cfd1d3 45%, var(--silver-lo) 100%);
  box-shadow: inset 0 0 0 0.16em #00000066, inset 0 0 1.4em #ffffff66, 0 0.6em 1em #0004;
  outline: 0.16em solid #00000022;
}
.bezel-title, .bezel-sub {
  text-align: center;
  font: 800 2.1em/1 "Arial Narrow", Arial, sans-serif;
  letter-spacing: 0.16em;
  color: var(--ink);
  position: relative;
}
.bezel-title { margin-bottom: .55em; }
.bezel-sub { margin-top: .55em; font-size: 1.7em; letter-spacing: 0.22em; }
/* decorative side dashes around titles */
.bezel-title::before, .bezel-title::after,
.bezel-sub::before, .bezel-sub::after {
  content: ""; position: absolute; top: 50%; width: 1.4em; height: 0.12em;
  background: var(--ink);
}
.bezel-title::before, .bezel-sub::before { right: calc(50% + 5.6em); }
.bezel-title::after,  .bezel-sub::after  { left:  calc(50% + 5.6em); }
.bezel-sub::before { right: calc(50% + 6.2em); }
.bezel-sub::after  { left:  calc(50% + 6.2em); }

.lcd-frame {
  position: relative;
  border-radius: 0.8em;
  padding: 0.7em;
  background: linear-gradient(150deg, var(--lavender-lite), var(--lavender) 70%, var(--lavender-dark));
  box-shadow: inset 0 0 0 0.14em #00000033;
}
#lcd {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 600 / 400;
  border-radius: 0.35em;
  background: linear-gradient(160deg, var(--lcd-bg2) 0%, var(--lcd-bg) 55%, #a4aa8c 100%);
  box-shadow: inset 0 0 1.2em #6f745c66, inset 0 0 0 0.12em #00000040;
  image-rendering: auto;
}
#lcd-overlay {
  position: absolute; inset: 0.7em;
  border-radius: 0.35em;
  pointer-events: none;
  background: linear-gradient(115deg, #ffffff30 0%, #ffffff08 22%, #ffffff00 40%);
}

/* ---------- Right column ---------- */
.col-right { display: flex; flex-direction: column; align-items: center; justify-content: space-between; }
.mode-buttons {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 0.35em 0.6em;
  margin-top: .3em;
}
.mode-lbl {
  display: flex; align-items: center; gap: 0.4em;
  font-size: 1.3em; white-space: nowrap;
}
.mode-lbl em { font-style: normal; font-size: 0.82em; color: #333; }
.led {
  width: 0.7em; height: 0.7em; border-radius: 50%;
  background: #3a3a3a; box-shadow: inset 0 0 0.2em #000;
  display: inline-block; margin-left: 0.3em;
}
.dpad {
  display: flex; flex-direction: column; align-items: center; gap: 0.5em;
  margin-bottom: 1em;
}
.dir-lbl { display: flex; align-items: center; gap: 0.4em; font-size: 1.5em; }
.dir-lbl b { font-size: 0.9em; }
.dpad .hw-red { width: 5.8em; height: 5.8em; }

/* ---------- Modal ---------- */
#modal {
  position: fixed; inset: 0; z-index: 50;
  background: #000000b0;
  display: none;
  align-items: center; justify-content: center;
  padding: 16px;
}
#modal.is-open { display: flex; }
.modal-card {
  position: relative;
  max-width: 540px; width: 100%;
  max-height: 82vh; overflow-y: auto;
  background: #f6f4ef; color: #222;
  border-radius: 14px;
  padding: 28px 26px;
  box-shadow: 0 20px 60px #000a;
}
.modal-close {
  position: absolute; top: 10px; right: 14px;
  font-size: 28px; line-height: 1;
  background: none; border: none; cursor: pointer; color: #888;
}
.modal-close:hover { color: #222; }
.modal-body h2 { margin: 0 0 6px; color: var(--lavender-dark); }
.modal-body h3 { margin: 20px 0 6px; }
.modal-body p, .modal-body li { line-height: 1.55; font-size: 15px; }
.modal-body kbd {
  display: inline-block; min-width: 20px; text-align: center;
  padding: 2px 7px; margin: 0 1px;
  font: 600 13px/1.4 Menlo, monospace;
  background: #fff; border: 1px solid #ccc; border-bottom-width: 2px;
  border-radius: 5px; color: #333;
}
.modal-body table { border-collapse: collapse; width: 100%; margin-top: 8px; }
.modal-body td { padding: 7px 4px; border-bottom: 1px solid #e2e0da; font-size: 15px; }
.modal-body a { color: var(--lavender-dark); }
.share-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.share-row button {
  padding: 9px 14px; border-radius: 8px; border: 1px solid #ccc;
  background: #fff; cursor: pointer; font-size: 14px;
}
.share-row button:hover { background: #eee; }

/* ---------- Fullscreen mode ---------- */
#stage.is-full { padding: 44px 4px 4px; }

/* Landscape hint for narrow portrait phones */
#rotate-hint {
  position: fixed; inset: 0; z-index: 60;
  display: none;
  align-items: center; justify-content: center;
  background: #1b1a20ee; color: #eee; text-align: center;
  font-size: 18px; padding: 30px;
}
#rotate-hint.show { display: flex; }
