/* 界面模块：掌机外壳、液晶屏、按键 */
:root {
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #3ec4e6;
  font-family: "PingFang SC", "Microsoft YaHei", "Heiti SC", "Noto Sans SC", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

button { font-family: inherit; }

.device {
  --lcd: #9ead86;
  --lcd-deep: #879372;
  --ink: #000;
  --ghost: #879372;
  --grid: #879372;
  --gold: #4eccea;
  --gold-deep: #1b7f99;
  position: relative;
  flex: none;
  width: 380px;
  height: auto;
  display: flex;
  flex-direction: column;
  padding: 12px 8px 20px;
  background:
    radial-gradient(120% 40% at 50% -10%, rgba(255, 255, 255, 0.34), transparent 46%),
    linear-gradient(180deg, #8ae4f8 0%, #4eccea 42%, #2eb8dc 100%);
  overflow: hidden;
  touch-action: none;
  transform-origin: center center;
}

.device.skin-amber {
  --lcd: #f3e2b4;
  --lcd-deep: #e6d09a;
  --ink: #3a2912;
  --ghost: rgba(70, 46, 12, 0.22);
  --grid: rgba(92, 64, 22, 0.28);
}

.device.skin-aqua {
  --lcd: #c5e6ee;
  --lcd-deep: #b3d7e2;
  --ink: #102830;
  --ghost: rgba(12, 40, 52, 0.2);
  --grid: rgba(18, 62, 74, 0.26);
}

.device.skin-gray {
  --lcd: #d7ddd4;
  --lcd-deep: #c8cfc4;
  --ink: #222422;
  --ghost: rgba(20, 20, 20, 0.2);
  --grid: rgba(30, 30, 30, 0.24);
}

.stage {
  position: relative;
  flex: none;
  margin-bottom: 26px;
}

.bezel {
  height: auto;
  margin: 0 4px;
  padding: 0;
  border-radius: 2px;
  background: transparent;
  box-shadow: none;
}

.lcd.is-off .lcd-main,
.lcd.is-off .lcd-foot,
.lcd.is-off .scan,
.lcd.is-off .glass,
.lcd.is-off .lcd-overlay {
  visibility: hidden;
}

.lcd.is-off {
  background: #c9ccc2;
  box-shadow: none;
}

.bezel-gold {
  height: auto;
  border: 5px solid;
  border-color: #1b7f99 #d7f7ff #d7f7ff #1b7f99;
  background: #9ead86;
  box-shadow: none;
}

.lcd {
  position: relative;
  height: auto;
  display: flex;
  flex-direction: column;
  background: #9ead86;
  border: 2px solid #494536;
  overflow: hidden;
  box-shadow: inset 0 0 10px #fff;
}

.lcd.shock { animation: lcd-shock 0.45s linear; }
.lcd.victory { animation: lcd-win 0.7s ease; }
.lcd.thud { animation: lcd-thud 0.16s linear; }
.lcd.rumble { animation: lcd-rumble 0.32s linear; }

@keyframes lcd-shock {
  0%, 100% { filter: none; }
  25% { filter: contrast(1.45) brightness(1.35); }
  55% { filter: contrast(0.9) brightness(0.92); }
}

@keyframes lcd-win {
  0%, 100% { filter: none; }
  30% { filter: sepia(0.35) brightness(1.25); }
  60% { filter: sepia(0.15) brightness(1.08); }
}

@keyframes lcd-thud {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(2px); }
}

@keyframes lcd-rumble {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-1px, 2px); }
  45% { transform: translate(1px, -1px); }
  70% { transform: translate(-1px, 1px); }
}

.lcd-main {
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
  padding: 8px;
  position: relative;
  z-index: 2;
}

.well {
  flex: 0 0 auto;
  min-width: 0;
  position: relative;
  border: 2px solid #000;
  align-self: flex-start;
}

.well canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.panel {
  flex: 0 0 112px;
  width: 112px;
  align-self: flex-start;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  padding: 12px 0 0;
}

.lcd-word {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-weight: 700;
  font-stretch: normal;
  font-size: 17px;
  letter-spacing: 0.04em;
  line-height: 1.2;
  color: var(--ink);
}

.toy-pair {
  width: 100%;
  display: flex;
  justify-content: space-evenly;
  align-items: center;
}

.toy-caption {
  justify-content: center;
  gap: 6px;
}

.maker {
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-align: center;
}

.score-now { width: auto; gap: 2px; }
.score-now .digit {
  flex: 0 0 16px;
  width: 16px;
  max-width: 16px;
  height: 28px;
  aspect-ratio: auto;
}

.score-read { width: auto; gap: 2px; }
.score-read .digit {
  flex: 0 0 16px;
  width: 16px;
  max-width: 16px;
  height: 28px;
  aspect-ratio: auto;
}

.score-tag {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--ink);
}

.note {
  font-family: "Segoe UI Symbol", "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
  color: var(--ink);
}
.note.is-off { color: #879372; }

.panel canvas {
  width: auto;
  height: auto;
  max-width: 100%;
  display: block;
}

.stat { text-align: center; min-width: 0; }

.label {
  font-size: clamp(12px, 3.3vw, 16px);
  font-weight: 800;
  letter-spacing: 1px;
  line-height: 1.15;
  color: var(--ink);
}

.digits {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2px;
  margin-top: 1px;
  transform: skewX(-8deg);
  transform-origin: center bottom;
}

.digit {
  position: relative;
  flex: 1 1 0;
  max-width: 22px;
  aspect-ratio: 10 / 18;
}

.digit i {
  position: absolute;
  background: #879372;
}

.digit i.on { background: #000; }

.digit .a, .digit .g, .digit .d {
  height: 16%;
  left: 16%;
  right: 16%;
  clip-path: polygon(14% 50%, 24% 0, 76% 0, 86% 50%, 76% 100%, 24% 100%);
}

.digit .a { top: 0; }
.digit .g { top: 42%; }
.digit .d { bottom: 0; }

.digit .b, .digit .c, .digit .e, .digit .f {
  width: 22%;
  clip-path: polygon(0 16%, 50% 0, 100% 16%, 100% 84%, 50% 100%, 0 84%);
}
.digit .f, .digit .b { top: 3%; height: 46%; }
.digit .e, .digit .c { bottom: 3%; height: 46%; }
.digit .f, .digit .e { left: 0; }
.digit .b, .digit .c { right: 0; }

.next canvas {
  width: 78%;
  max-height: 72px;
  aspect-ratio: 4 / 3;
  margin: 2px auto 0;
  display: block;
}

.lcd-foot {
  position: relative;
  z-index: 2;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 3px;
  color: var(--ink);
}

.status {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.2;
  min-height: 1em;
  color: var(--ink);
}

.status.blink { animation: blink 1s steps(1, end) infinite; }

@keyframes blink {
  50% { opacity: 0.25; }
}

.clockbox {
  display: flex;
  align-items: center;
  gap: 4px;
}

.spk { width: 16px; height: 16px; display: block; }
.spk .wave { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; }
.spk .body { fill: var(--ink); }
.spk .slash { display: none; stroke: var(--ink); stroke-width: 1.6; }
.spk.is-muted .wave { opacity: 0.25; }
.spk.is-muted .slash { display: block; }

.digits.tiny {
  width: 62px;
  height: 18px;
  flex: none;
}

.digits.tiny .digit {
  flex: 0 0 11px;
  width: 11px;
  min-width: 11px;
  max-width: 11px;
  height: 18px;
  aspect-ratio: auto;
}

.colon {
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  color: var(--ink);
  margin: 0 1px;
}

.lcd-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(215, 228, 184, 0.42);
}

.lcd-overlay.show { display: flex; }

.lcd-overlay strong {
  display: block;
  font-size: clamp(28px, 8vw, 40px);
  letter-spacing: 6px;
  color: var(--ink);
  border: 3px solid var(--ink);
  background: rgba(255, 255, 255, 0.38);
  padding: 6px 14px 8px;
  text-indent: 6px;
}

.lcd-overlay em {
  display: block;
  margin-top: 8px;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--ink);
}

.lcd-overlay.pause { background: transparent; }
.lcd-overlay.pause strong {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  border: 0;
  background: none;
  padding: 0;
  text-indent: 0;
  animation: blink 0.65s steps(1, end) infinite;
}
.lcd-overlay.pause em { display: none; }
.lcd-overlay.win strong,
.lcd-overlay.fail strong {
  font-size: 20px;
  letter-spacing: 1px;
  padding: 4px 8px;
}

.scan, .glass {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scan {
  z-index: 5;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.05) 0,
    rgba(255, 255, 255, 0.05) 1px,
    transparent 1px,
    transparent 4px
  );
  animation: scanflicker 5.5s infinite;
}

.glass {
  z-index: 6;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent 10%);
}

@keyframes scanflicker {
  0%, 92%, 100% { opacity: 0.55; }
  94% { opacity: 0.3; }
  96% { opacity: 0.6; }
}

.menu {
  flex: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  justify-items: center;
  margin: 8px 8px 0;
  padding-bottom: 30px;
}

.mitem {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.mitem span {
  color: #111;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
  text-shadow: none;
  white-space: nowrap;
  pointer-events: none;
}

.orb {
  --face: #f2c400;
  position: relative;
  border: 1px solid #111;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  touch-action: none;
  background: var(--face);
  box-shadow: none;
}

.orb::before,
.orb::after { content: none; }

.tone-red { --face: #e53935; }
.tone-green { --face: #43a047; }
.tone-yellow { --face: #f2c400; }
.tone-orange { --face: #f57c00; }

.orb:focus { outline: none; }
.orb:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.8); outline-offset: 3px; }

.menu-btn {
  width: 26px;
  height: 26px;
}

.orb.is-down,
.orb.latched { filter: brightness(0.92); }

.controls {
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 6px 6px 4px 4px;
}

.dpad {
  display: grid;
  grid-template-areas:
    ". up ."
    "left mid right"
    ". down .";
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
  gap: 1px;
  margin: 12px 6px 8px 26px;
}

.slot {
  position: relative;
  min-width: 0;
  min-height: 0;
}

.slot span,
.spin span {
  position: absolute;
  color: #111;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
  pointer-events: none;
}
.slot.up span { left: calc(100% + 4px); top: 50%; transform: translateY(-50%); }
.slot.down span { left: 50%; top: calc(100% + 2px); transform: translateX(-50%); }
.slot.left span { right: calc(100% + 4px); top: 50%; transform: translateY(-50%); }
.slot.right span { left: calc(100% + 4px); top: 50%; transform: translateY(-50%); }
.spin span { position: static; }
.slot.up { grid-area: up; }
.slot.left { grid-area: left; }
.slot.right { grid-area: right; }
.slot.down { grid-area: down; }
.slot.mid {
  grid-area: mid;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.pad-arrows {
  position: relative;
  width: 26px;
  height: 26px;
}

.pad-arrows b {
  position: absolute;
  width: 0;
  height: 0;
  border: 5px solid transparent;
}

.pad-arrows .n {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  border-bottom-color: #111;
  border-top-width: 0;
  border-bottom-width: 7px;
}

.pad-arrows .s {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  border-top-color: #111;
  border-bottom-width: 0;
  border-top-width: 7px;
}

.pad-arrows .w {
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  border-right-color: #111;
  border-left-width: 0;
  border-right-width: 7px;
}

.pad-arrows .e {
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  border-left-color: #111;
  border-right-width: 0;
  border-left-width: 7px;
}

.pad-btn {
  width: 52px;
  height: 52px;
  flex: none;
}

.spin {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  width: auto;
  margin: 42px 0 0 2px;
  flex: none;
}

.spin-btn {
  width: 54px;
  height: 54px;
  flex: none;
}

@media (prefers-reduced-motion: reduce) {
  .scan, .status.blink, .lcd-overlay.pause strong, .lcd.shock, .lcd.victory, .lcd.thud, .lcd.rumble { animation: none; }
}
