/* ============================================================
   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;
  /* The console is scaled via a tiny JS-set root font-size. Mobile
     browsers otherwise "boost" text above its em size, which warps the
     whole layout. Pin text sizing so it scales uniformly like desktop. */
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ---------------- 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; }
/* anchor menu items (e.g. Source download) match the buttons */
a.menu-item { display: block; text-decoration: none; box-sizing: border-box; }

/* ---------------- 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,                    /* drop shadow */
    inset 0 0.55em 0.7em #ffffff5c,     /* top bevel highlight (raised) */
    inset 0 -1.5em 2.4em #00000048,     /* bottom bevel shadow */
    inset 0 0 0 .25em #ffffff30;
  user-select: none;
  touch-action: manipulation;
}

.face {
  width: 100%; height: 100%;
  border-radius: 4.5em;
  background:
    /* silvery diagonal sheen for a shiny metallic tint */
    linear-gradient(118deg, #ffffff66 0%, #ffffff00 26%, #ffffff1f 52%, #ffffff00 70%, #ffffff3a 100%),
    repeating-linear-gradient(92deg, #ffffff00 0 .18em, #00000008 .18em .36em),
    linear-gradient(150deg, #e4ddca 0%, #cdc7b4 46%, #b6ad90 100%);
  box-shadow: inset 0 0 0 .18em #00000022, inset 0 0 1.6em #8a8a7a44;
  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 0;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  /* Snoopy-with-racket mascot */
  background-image: url("../about/images/png/snoopy_ready.png");
}
.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: 5.1em; height: 5.1em;      /* ~20% smaller */
  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: 3.9em; height: 2.1em;      /* ~15% smaller */
  border-radius: 1.4em;
  background: linear-gradient(#d3cfc7, var(--grey-btn) 60%, #a29e96);
  /* purple boundary with a slight drop shadow (matches the real device) */
  border: 0.16em solid var(--lavender-dark);
  box-shadow: 0 0.4em 0.55em #0006, 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; }

/* push HIT down off the mascot, then lift it so it sits at roughly the
   vertical midpoint of the UP/DOWN buttons opposite it */
.col-left .hw-red { margin-top: auto; margin-bottom: 5em; }
.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;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  letter-spacing: 0.1em;
}
.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));
  /* embossed: raised off the bezel with a highlight above and shadow below */
  box-shadow:
    0 0.5em 0.9em #00000055,          /* elevation drop shadow */
    0 -0.12em 0 #ffffff4d,            /* top highlight edge */
    inset 0 0.16em 0.2em #ffffff55,   /* inner top bevel */
    inset 0 -0.16em 0.3em #00000040,  /* inner bottom bevel */
    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: 2.1em 0.6em;             /* more vertical space between the buttons */
  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: 4.6em; height: 4.6em; }   /* ~20% smaller */

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

/* On phones/touch devices only the 100% (Full) size is offered -
   the intermediate size warps the layout on small screens. */
@media (max-width: 820px), (pointer: coarse) {
  .size-btn[data-size="80"] { display: none; }
}

/* Phone in portrait: the landscape console can't fit nicely, so cover
   it with the rotate hint (CSS-driven so it works without JS). */
@media (orientation: portrait) and (max-width: 900px) {
  #rotate-hint { display: flex; }
  #stage, #topbar, #live-count { display: none; }
}

/* ---------------- Live visitor badge ---------------- */
#live-count {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 35;                 /* above stage, below menu/modal */
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  font: 500 12px/1 Arial, sans-serif;
  color: #eee;
  background: #2c2a33cc;
  border: 1px solid #ffffff22;
  border-radius: 999px;
  box-shadow: 0 4px 14px #0006;
  backdrop-filter: blur(4px);
  pointer-events: none;        /* purely informational — never intercept taps */
  user-select: none;
}
#live-count[hidden] { display: none; }
#live-count b { color: #fff; }
#live-count .live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #46d17a;
  box-shadow: 0 0 0 0 #46d17a99;
  animation: live-pulse 2s ease-out infinite;
}
@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 #46d17a88; }
  70%  { box-shadow: 0 0 0 7px #46d17a00; }
  100% { box-shadow: 0 0 0 0 #46d17a00; }
}
@media (prefers-reduced-motion: reduce) {
  #live-count .live-dot { animation: none; }
}
