@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@100..900&display=swap");

@font-face {
  font-family: "DSEG7ClassicBold";
  src: url("../fonts/DSEG7Classic-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg-top: #05070d;
  --bg-bottom: #121824;
  --panel: rgba(9, 12, 18, 0.82);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text-main: #f8fafc;
  --text-sub: #cbd5e1;
  --text-soft: #94a3b8;
  --accent: #ef4444;
  --accent-strong: #dc2626;
  --gold: #fbbf24;
  --gold-soft: rgba(251, 191, 36, 0.24);
  --green: #22c55e;
  --cyan: #38bdf8;
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 18px 42px rgba(0, 0, 0, 0.42);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --font-main: "Noto Sans Japanese Variable", "Noto Sans JP", sans-serif;
  --page-pad-x: 16px;
  --page-pad-top: 24px;
  --page-pad-bottom: 40px;
  --viewport-width: 100vw;
  --viewport-height: 100dvh;
  --app-frame-width: 390px;
  --app-frame-height: 763px;
  --app-frame-left: 0px;
  --app-frame-top: 0px;
  --desktop-preview-padding: 0px;
  --machine-ui-gap: 10px;
  --machine-marquee-height: 44px;
  --machine-lamp-size: 292px;
  --machine-lamp-scale: 1.2;
  --machine-patrol-width: min(25%, clamp(72px, 11svh, 102px));
  --machine-patrol-height: calc(var(--machine-patrol-width) * 0.8);
  --machine-push-width: 248px;
  --machine-push-scale: 1.2;
  --machine-side-button-size: 60px;
  --machine-status-value-size: 1.45rem;
  --machine-status-label-size: 0.68rem;
  --machine-status-text-scale: 1.5;
  --machine-marquee-font-scale: 1.08;
  --machine-marquee-text-size: calc(0.95rem * var(--machine-marquee-font-scale));
  --machine-safe-top-dynamic: 16px;
  --machine-safe-right-dynamic: 16px;
  --machine-safe-bottom-dynamic: 18px;
  --machine-safe-left-dynamic: 16px;
  --machine-safe-top: 16px;
  --machine-safe-right: 16px;
  --machine-safe-bottom: 18px;
  --machine-safe-left: 16px;
}

* {
  box-sizing: border-box;
}

html {
  font-feature-settings: "palt" on;
  letter-spacing: 0.05rem;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-main);
  color: var(--text-main);
  background:
    radial-gradient(circle at top, rgba(239, 68, 68, 0.2), transparent 24%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body {
  padding:
    calc(var(--page-pad-top) + env(safe-area-inset-top))
    calc(var(--page-pad-x) + env(safe-area-inset-right))
    calc(var(--page-pad-bottom) + env(safe-area-inset-bottom))
    calc(var(--page-pad-x) + env(safe-area-inset-left));
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

body:not(.admin-page) {
  overscroll-behavior: none;
}

body:not(.admin-page) .machine-safe,
body:not(.admin-page) .push-button,
body:not(.admin-page) .side-button,
body:not(.admin-page) .sound-toggle,
body:not(.admin-page) .entry-panel__actions .secondary-button,
body:not(.admin-page) .modal-actions button {
  touch-action: none;
}

body:not(.admin-page) .result-card,
body:not(.admin-page) .history-list {
  touch-action: pan-y;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

.app-shell {
  width: min(100%, 1120px);
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

body.admin-page .app-shell {
  width: min(100%, 1480px);
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  align-items: start;
}

body.admin-page .hero-card {
  grid-column: 1 / -1;
}

body.admin-page .admin-settings-panel {
  grid-column: 1;
}

body.admin-page .admin-preview-panel {
  grid-column: 2;
  position: sticky;
  top: calc(24px + env(safe-area-inset-top));
}

.hero-card,
.panel,
.game-stage {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.hero-card {
  position: relative;
  overflow: hidden;
  padding: 30px 24px;
}

.hero-card::after {
  content: "";
  position: absolute;
  inset: auto -40px -60px auto;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(251, 191, 36, 0.26), transparent 70%);
  pointer-events: none;
}

.eyebrow {
  color: var(--text-soft);
  font-size: 0.8rem;
  letter-spacing: 0.05rem;
  text-transform: uppercase;
}

h1 {
  margin-top: 10px;
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  line-height: 1.05;
}

.lead {
  margin-top: 12px;
  color: var(--text-sub);
  line-height: 1.8;
}

.panel,
.game-stage {
  padding: 22px 18px;
}


.entry-panel {
  position: fixed;
  inset: 0;
  z-index: 24;
  display: grid;
  align-items: stretch;
  justify-items: center;
  padding:
    max(18px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  background: #02040a center / cover no-repeat url("../image/ui_start_bg.webp");
  backdrop-filter: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

body[data-phase="idle"] .entry-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

body[data-phase="idle"] .machine .control-row {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.entry-panel__card {
  width: 100%;
  max-width: 390px;
  min-height: 100%;
  margin: 0;
  justify-self: center;
  position: relative;
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 12px;
  padding:
    calc(var(--machine-marquee-height) + 6px)
    0
    calc(var(--machine-safe-bottom) + var(--machine-side-button-size) + 18px);
}

.entry-panel__actions {
  width: min(100%, 312px);
  justify-self: center;
  margin-top: 0;
}

.entry-panel__actions .secondary-button {
  width: 100%;
  min-height: 62px;
  font-size: 1.08rem;
}

.entry-panel__actions #start-button {
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: transparent url("../image/ui_start_button.webp") center / 100% 100% no-repeat;
  box-shadow: none;
  aspect-ratio: 1105 / 294;
  font-size: 0;
}

.entry-marquee {
  position: fixed;
  top: env(safe-area-inset-top);
  left: env(safe-area-inset-left);
  right: env(safe-area-inset-right);
  z-index: 25;
  overflow: hidden;
  min-height: var(--machine-marquee-height);
  display: flex;
  align-items: center;
  border-radius: 0;
  border: 2px solid rgba(255, 255, 255, 0.18);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 45%),
    #080b12;
  box-shadow:
    inset 0 -6px 12px rgba(0, 0, 0, 0.48),
    inset 0 2px 4px rgba(255, 255, 255, 0.08);
}

.entry-marquee__track {
  display: flex;
  gap: 0;
  min-width: max-content;
  animation: marquee var(--marquee-duration, 14s) linear infinite;
  will-change: transform;
}

.entry-marquee__copy {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding-inline: 0 28px;
  font-family: var(--font-main);
  font-size: var(--machine-marquee-text-size);
  line-height: 1;
  letter-spacing: 0.05rem;
  color: #ffffff;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.28);
}

.setting-marquee__accent {
  color: #fde68a;
}

.entry-logo-slot {
  width: calc(100% + var(--machine-safe-left) + var(--machine-safe-right));
  margin-top: -12px;
  margin-inline-start: calc(var(--machine-safe-left) * -1);
  margin-inline-end: calc(var(--machine-safe-right) * -1);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 0;
  padding: 0;
  text-align: center;
}

.entry-logo-slot__image {
  width: 100%;
  max-width: none;
  height: auto;
  max-height: none;
  display: block;
  object-fit: contain;
  filter:
    drop-shadow(0 14px 28px rgba(0, 0, 0, 0.34))
    drop-shadow(0 0 20px rgba(255, 255, 255, 0.08));
}

.entry-best-card {
  width: min(100%, 342px);
  aspect-ratio: 1106 / 596;
  position: relative;
  display: block;
  justify-self: center;
  text-align: center;
  border: none;
  border-radius: 0;
  background: center / 100% 100% no-repeat url("../image/ui_start_kami.webp");
  box-shadow: none;
}

.entry-best-card__content {
  position: absolute;
  top: 47%;
  left: 50%;
  width: min(88%, 270px);
  display: grid;
  justify-items: center;
  gap: clamp(6px, 1.8vw, 10px);
  transform: translate(-50%, -50%);
}

.entry-best-card__name {
  width: 100%;
  max-width: none;
  font-size: clamp(1.35rem, 5.8vw, 1.95rem);
  line-height: 1.16;
  font-weight: 700;
  color: #fde68a;
  word-break: break-word;
  text-align: center;
  text-shadow:
    0 2px 10px rgba(32, 0, 0, 0.82),
    0 0 12px rgba(32, 0, 0, 0.42);
}

.entry-best-card__name-accent {
  display: inline-flex;
  align-items: flex-end;
  color: #fde68a;
}

.entry-best-card__stats {
  width: 100%;
  max-width: none;
  font-family: var(--font-main);
  font-size: clamp(0.92rem, 4vw, 1.18rem);
  line-height: 1.28;
  color: #ffffff;
  text-align: center;
  text-shadow:
    0 2px 10px rgba(32, 0, 0, 0.82),
    0 0 12px rgba(32, 0, 0, 0.42);
}

.entry-panel__field-grid {
  width: min(100%, 312px);
  justify-self: center;
  gap: 0;
}

.entry-field {
  width: 100%;
  gap: 10px;
  text-align: center;
}

.entry-field span {
  display: block;
  font-size: 0.92rem;
  color: var(--text-sub);
  text-align: center;
}

.entry-field input {
  min-height: 64px;
  border-radius: 18px;
  font-size: 1.18rem;
  text-align: center;
}

.entry-panel__controls {
  margin-top: 0;
  padding-top: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.admin-settings-panel,
.admin-preview-panel {
  display: grid;
  gap: 16px;
}

.admin-preview-actions {
  margin-top: 0;
}

.admin-preview-shell {
  display: grid;
  place-items: center;
  padding: 18px;
  overflow-x: auto;
  overflow-y: visible;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 44%),
    rgba(5, 8, 15, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 18px rgba(251, 191, 36, 0.05);
}

.admin-preview-frame {
  width: 390px;
  min-width: 390px;
  height: 763px;
  min-height: 763px;
  display: block;
  flex: 0 0 auto;
  border: none;
  border-radius: 0;
  background: #020617;
  box-shadow: var(--shadow-lg);
}

.panel-heading {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.panel-heading p {
  color: var(--text-sub);
  line-height: 1.6;
}

.panel-heading--compact {
  margin-bottom: 12px;
}

.field-grid {
  display: grid;
  gap: 14px;
}

.two-column {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 0.95rem;
}

.field input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-sm);
  background: rgba(2, 6, 23, 0.86);
  color: var(--text-main);
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.field input[type="file"] {
  padding: 12px 14px;
}

.field input:focus {
  border-color: rgba(248, 113, 113, 0.86);
  transform: translateY(-1px);
}

.field-hint {
  color: var(--text-soft);
  font-size: 0.82rem;
  line-height: 1.6;
}

.admin-lamp-settings {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}

.prefixed-input {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-sm);
  background: rgba(2, 6, 23, 0.86);
  overflow: hidden;
}

.prefixed-input:focus-within {
  border-color: rgba(248, 113, 113, 0.86);
}

.prefixed-input__prefix {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 0 14px;
  color: #fde68a;
  font-family: var(--font-main);
  background: rgba(255, 255, 255, 0.05);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.prefixed-input input {
  border: none;
  border-radius: 0;
  background: transparent;
}

.prefixed-input input:focus {
  border-color: transparent;
  transform: none;
}

.action-row,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.action-row {
  margin-top: 16px;
}

.secondary-button,
.ghost-button {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  border: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.secondary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff7ed;
  box-shadow: 0 10px 24px rgba(239, 68, 68, 0.28);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.secondary-button:hover,
.ghost-button:hover,
.push-button:hover:not(:disabled),
.side-button:hover:not(:disabled),
.sound-toggle:hover:not(:disabled) {
  transform: translateY(-2px);
}

.secondary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.game-stage {
  background:
    radial-gradient(circle at top, rgba(251, 191, 36, 0.12), transparent 24%),
    var(--panel);
}

.stage-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.session-chip {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.16);
  color: #fecaca;
  font-size: 0.92rem;
}

.machine {
  position: relative;
  isolation: isolate;
  width: min(100%, 390px);
  aspect-ratio: 390 / 763;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 32px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.04),
    var(--shadow-lg);
  overscroll-behavior: none;
  background:
    radial-gradient(circle at center, rgba(82, 8, 8, 0.7), transparent 52%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0 7px, rgba(0, 0, 0, 0.03) 7px 14px),
    linear-gradient(180deg, #494949 0%, #20232d 12%, #420707 32%, #10070a 58%, #1d212c 100%);
}

.machine-bg-video {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.machine-led-shadow {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.96;
  filter: blur(8px);
}

.machine-led-shadow--left {
  left: 0;
  width: calc((var(--machine-safe-left) + 8px) * 1.2);
  background:
    linear-gradient(90deg, rgba(1, 4, 10, 0.98) 0%, rgba(1, 4, 10, 0.88) 24%, rgba(1, 4, 10, 0.58) 56%, rgba(1, 4, 10, 0.18) 78%, rgba(1, 4, 10, 0) 100%);
  box-shadow:
    inset -18px 0 26px rgba(0, 0, 0, 0.46),
    inset -42px 0 58px rgba(2, 6, 23, 0.6),
    inset -74px 0 92px rgba(2, 6, 23, 0.34);
}

.machine-led-shadow--right {
  right: 0;
  width: calc((var(--machine-safe-left) + 8px) * 1.2);
  background:
    linear-gradient(270deg, rgba(1, 4, 10, 0.98) 0%, rgba(1, 4, 10, 0.88) 24%, rgba(1, 4, 10, 0.58) 56%, rgba(1, 4, 10, 0.18) 78%, rgba(1, 4, 10, 0) 100%);
  box-shadow:
    inset 18px 0 26px rgba(0, 0, 0, 0.46),
    inset 42px 0 58px rgba(2, 6, 23, 0.6),
    inset 74px 0 92px rgba(2, 6, 23, 0.34);
}

.machine-safe {
  position: relative;
  z-index: 3;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--machine-ui-gap);
  padding:
    calc(var(--machine-safe-top) + var(--machine-marquee-height) + var(--machine-ui-gap))
    var(--machine-safe-right)
    var(--machine-safe-bottom)
    var(--machine-safe-left);
}

.machine::before,
.machine::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 50% 12%, rgba(255, 198, 230, 0.6) 0 7%, rgba(255, 255, 255, 0) 24%),
    linear-gradient(90deg, rgba(255, 120, 200, 0.34) 0%, rgba(255, 255, 255, 0.08) 18%, rgba(255, 255, 255, 0) 44%),
    repeating-linear-gradient(
      135deg,
      rgba(255, 194, 64, 0.24) 0 4px,
      rgba(255, 255, 255, 0.05) 4px 9px,
      rgba(255, 255, 255, 0) 9px 15px
    ),
    repeating-linear-gradient(
      180deg,
      rgba(255, 160, 210, 0.26) 0 2px,
      rgba(255, 255, 255, 0.05) 2px 10px,
      rgba(255, 220, 120, 0.22) 10px 12px,
      rgba(255, 255, 255, 0.04) 12px 24px
    ),
    repeating-linear-gradient(
      180deg,
      #ff1744 0 14px,
      #ff9100 14px 28px,
      #fff200 28px 42px,
      #00e676 42px 56px,
      #00e5ff 56px 70px,
      #2979ff 70px 84px,
      #d500f9 84px 98px,
      #ff4081 98px 112px
    ),
    linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0) 16%, rgba(255, 255, 255, 0.18) 48%, rgba(255, 255, 255, 0) 100%),
    linear-gradient(90deg, rgba(8, 12, 22, 0.94), rgba(13, 18, 30, 0.98));
  box-shadow:
    0 0 14px rgba(255, 120, 200, 0.5),
    0 0 32px rgba(255, 0, 128, 0.5),
    0 0 48px rgba(0, 229, 255, 0.5),
    inset -1px 0 0 rgba(255, 184, 229, 0.5),
    inset 0 0 14px rgba(255, 214, 92, 0.5);
  z-index: 1;
  pointer-events: none;
  animation:
    ledStream 3s linear infinite,
    ledPulse 2.1s linear infinite;
}

.machine::before {
  left: 0;
  width: calc(var(--machine-safe-left) + 2px);
}

.machine::after {
  right: 0;
  width: calc(var(--machine-safe-right) + 2px);
  box-shadow:
    0 0 14px rgba(255, 120, 200, 0.5),
    0 0 32px rgba(255, 0, 128, 0.5),
    0 0 48px rgba(0, 229, 255, 0.5),
    inset 1px 0 0 rgba(255, 184, 229, 0.5),
    inset 0 0 14px rgba(255, 214, 92, 0.5);
  animation-delay: -1.5s, -0.6s;
}

.machine-marquee {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 12;
  min-height: var(--machine-marquee-height);
  display: flex;
  align-items: center;
  overflow: hidden;
  border-radius: 0;
  border: 2px solid rgba(255, 255, 255, 0.18);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 45%),
    #080b12;
  box-shadow:
    inset 0 -6px 12px rgba(0, 0, 0, 0.48),
    inset 0 2px 4px rgba(255, 255, 255, 0.08);
}

.machine-marquee__track {
  display: flex;
  gap: 0;
  min-width: max-content;
  animation: marquee var(--marquee-duration, 14s) linear infinite;
  will-change: transform;
}

.machine-marquee__copy {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding-inline: 0 28px;
  color: #ffffff;
  font-family: var(--font-main);
  font-size: var(--machine-marquee-text-size);
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.05rem;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.28);
}

.patrol-row {
  display: flex;
  justify-content: space-between;
  padding-inline: 0;
  padding-inline-start: calc((var(--machine-safe-left) + 1px) * 2.0 - var(--machine-safe-left));
  padding-inline-end: calc((var(--machine-safe-right) + 1px) * 2.0 - var(--machine-safe-right));
  margin-top: calc((var(--machine-safe-top) + var(--machine-ui-gap)) * -1);
  position: relative;
  z-index: 10;
  transform: translateY(+12px);
}

.patrol-lamp {
  width: var(--machine-patrol-width);
  aspect-ratio: 300 / 300;
  background: center / contain no-repeat url("../image/ui_yugi_patlamp_off.webp");
  transition: background-image 0.05s ease-out;
}

.patrol-lamp.is-hit {
  background-image: url("../image/ui_yugi_patlamp_on.webp");
}

.machine-body {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding-block: 4px;
}

.side-button {
  width: var(--machine-side-button-size);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  align-self: center;
  margin-bottom: 0;
  padding: 0;
  border-radius: 50%;
  border: none;
  color: transparent;
  background: center / contain no-repeat;
  box-shadow: none;
}

.side-button:disabled {
  cursor: not-allowed;
  opacity: 1;
  transform: none;
}

.sound-toggle:disabled {
  cursor: not-allowed;
  opacity: 1;
  transform: none;
}

.side-button--help {
  justify-self: end;
  background-image: url("../image/ui_icon_help.webp");
}

.side-button--reset {
  justify-self: start;
  background-image: url("../image/ui_icon_retry.webp");
}

.center-stack {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 1.5svh, 14px);
  width: min(100%, clamp(264px, 40.8svh, 384px));
  margin-top: calc(var(--machine-patrol-height) * -1.25);
}


.main-lamp {
  width: min(100%, calc(var(--machine-lamp-size) * var(--machine-lamp-scale) * 1.1));
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 10;
  overflow: hidden;
  border-radius: 50%;
  border: none;
  background: center / contain no-repeat url("../image/ui_yugi_lampdaiza_off.webp");
  box-shadow: none;
  transition: transform 0.4s ease-out, box-shadow 0.6s ease-out, background 0.6s ease-out;
}

.main-lamp::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: center / contain no-repeat url("../image/ui_yugi_lampdaiza_on.webp");
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.2s ease-out;
}

.main-lamp::after {
  content: "";
  position: absolute;
  inset: 15%;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 247, 214, 0.68) 0%, rgba(255, 212, 97, 0.4) 24%, rgba(248, 113, 113, 0.34) 46%, rgba(239, 68, 68, 0.3) 62%, rgba(239, 68, 68, 0) 80%);
  opacity: 0;
  transform: scale(0.92);
  filter: blur(14px);
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.12s ease-out, transform 0.12s ease-out, filter 0.12s ease-out;
}

.main-lamp__image {
  width: 70%;
  max-width: 266px;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.36));
  position: relative;
  z-index: 10;
  transition: filter 0.18s ease-out, transform 0.18s ease-out, opacity 0.2s ease-out;
}

.main-lamp__image--on {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  filter:
    drop-shadow(0 0 16px rgba(255, 236, 153, 0.58))
    drop-shadow(0 0 30px rgba(239, 68, 68, 0.32))
    drop-shadow(0 10px 18px rgba(0, 0, 0, 0.28));
  transition: opacity 0.2s ease-out, filter 0.12s ease-out;
}

.main-lamp.is-hit .main-lamp__image--on {
  opacity: 1;
  transition: opacity 0.05s ease-out, filter 0.05s ease-out;
}

.main-lamp.is-hit {
  box-shadow:
    0 0 42px rgba(248, 113, 113, 0.48),
    0 0 88px rgba(239, 68, 68, 0.34),
    0 0 132px rgba(127, 29, 29, 0.22);
  transition: transform 0.05s ease-out, box-shadow 0.05s ease-out, background 0.05s ease-out;
}

.main-lamp.is-hit::before {
  opacity: 1;
  transition: opacity 0.05s ease-out;
}

.main-lamp.is-hit::after {
  opacity: 1;
  transform: scale(1.05);
  filter: blur(6px);
}

.push-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  overflow: visible;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.machine-kyoutai {
  position: absolute;
  left: 50%;
  top: calc(50% - var(--machine-push-width) * var(--machine-push-scale) * 0.24);
  z-index: 0;
  width: calc(var(--machine-push-width) * var(--machine-push-scale) * 2.8);
  aspect-ratio: 1290 / 884;
  transform: translateX(-50%);
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.push-button {
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  width: min(98.4%, calc(var(--machine-push-width) * var(--machine-push-scale) * 0.9));
  min-height: 0;
  aspect-ratio: 630 / 350;
  padding: 0;
  display: grid;
  place-items: center;
  position: relative;
  border: none;
  border-radius: 0;
  color: transparent;
  background: center / contain no-repeat url("../image/ui_yugi_push_on.webp");
  box-shadow: none;
  transition: transform 0.08s ease, filter 0.18s ease;
  z-index: 3;
}

.push-button:focus,
.push-button:focus-visible {
  outline: none;
}

.push-button:active:not(:disabled),
.push-button.is-pressed {
  background-image: url("../image/ui_yugi_push_off.webp");
  transform: translateY(3px) scale(0.985);
}

.push-button:disabled {
  cursor: not-allowed;
  background-image: url("../image/ui_yugi_push_off.webp");
  filter: none;
}

.push-button.is-locked {
  background-image: url("../image/ui_yugi_push_off.webp");
  filter: none;
}

.push-button__label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.status-strip {
  width: 100%;
  padding: 12px 14px;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 55%),
    rgba(2, 6, 23, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.status-label {
  color: #fdba74;
  font-family: var(--font-main);
  font-size: 0.86rem;
  letter-spacing: 0.05rem;
  text-transform: uppercase;
}

.status-message {
  margin-top: 8px;
  color: var(--text-sub);
  font-size: 0.88rem;
  line-height: 1.55;
}

.status-board {
  position: relative;
  z-index: 13;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 0;
  width: calc(100% + var(--machine-safe-left) + var(--machine-safe-right));
  margin-inline-start: calc(var(--machine-safe-left) * -1);
  margin-inline-end: calc(var(--machine-safe-right) * -1);
  margin-top: calc((var(--machine-safe-top) + var(--machine-ui-gap)) * -1);
  border-radius: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.04) 40%, rgba(255, 255, 255, 0.02) 100%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03) 38%, rgba(255, 255, 255, 0.01) 100%),
    rgba(9, 14, 24, 0.42);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    inset 0 -10px 18px rgba(4, 8, 18, 0.24),
    0 12px 28px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(14px) saturate(1.18);
  -webkit-backdrop-filter: blur(14px) saturate(1.18);
}

.status-card {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  padding: clamp(12px, 1.62svh, 16.8px) clamp(8px, 1.2vw, 12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 1svh, 10px);
  text-align: center;
}

.status-card + .status-card::before {
  content: "｜";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.82);
  font-family: var(--font-main);
  font-size: calc(var(--machine-status-value-size) * var(--machine-status-text-scale) * 1.05);
  line-height: 1;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.14);
}

.status-card__label {
  display: block;
  color: #ffffff;
  width: 100%;
  font-size: calc(var(--machine-status-label-size) * var(--machine-status-text-scale) * 1.2);
  line-height: 1.1;
  white-space: nowrap;
  text-align: center;
}

.status-card__value {
  display: block;
  width: 100%;
  color: #ffffff;
  font-family: "DSEG7ClassicBold", var(--font-main);
  font-size: calc(var(--machine-status-value-size) * var(--machine-status-text-scale) * 1.2);
  line-height: 1;
  letter-spacing: 0.08rem;
  white-space: nowrap;
  text-align: center;
}

.status-card__value--odds {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.03em;
}

.status-card__value--games {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.04em;
}

.status-card__games-number {
  line-height: 1;
}

.status-card__games-unit {
  display: inline-block;
  font-size: 0.6em;
  line-height: 1.1;
}

.status-card__odds-number {
  line-height: 1;
}

.status-card__odds-slash {
  display: inline-block;
  line-height: 1;
  transform: translateY(-0.2em);
}

.status-card__value.is-warning {
  color: #f87171;
  text-shadow: 0 0 16px rgba(239, 68, 68, 0.3);
}

.hit-flash-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 12;
  background:
    radial-gradient(circle at center, rgba(255, 248, 248, 0.3), rgba(255, 18, 18, 0.68) 30%, rgba(116, 0, 0, 0.94) 100%);
}

.hit-flash-overlay.is-active {
  animation: hitFlashRed 1.8s ease-out;
}

.control-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  width: calc(100% + var(--machine-safe-left) + var(--machine-safe-right));
  margin-inline-start: calc(var(--machine-safe-left) * -1);
  margin-inline-end: calc(var(--machine-safe-right) * -1);
  padding-inline: calc(var(--machine-safe-left) + 10px) calc(var(--machine-safe-right) + 10px);
  margin-top: auto;
  position: relative;
  z-index: 3;
}

.control-row--entry {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--machine-safe-bottom);
  width: auto;
  margin: 0;
  margin-inline-start: 0;
  margin-inline-end: 0;
  padding-inline: calc(var(--machine-safe-left) + 10px) calc(var(--machine-safe-right) + 10px);
  z-index: 26;
}

.sound-toggle {
  justify-self: center;
  width: var(--machine-side-button-size);
  min-height: 0;
  aspect-ratio: 1;
  padding: 0;
  border: none;
  border-radius: 50%;
  color: transparent;
  background: center / contain no-repeat url("../image/ui_icon_bgmon.webp");
  box-shadow: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.sound-toggle[data-enabled="false"] {
  background-image: url("../image/ui_icon_bgmoff.webp");
}

.machine-overlay {
  position: absolute;
  inset: 0;
  padding:
    calc(var(--machine-safe-top) + 10px)
    calc(var(--machine-safe-right) + 2px)
    calc(var(--machine-safe-bottom) + 10px)
    calc(var(--machine-safe-left) + 2px);
  display: grid;
  place-items: center;
  background: rgba(2, 6, 23, 0.82);
  z-index: 8;
}

.machine-overlay--result {
  background: rgba(2, 6, 23, 0.88);
}

.countdown-card,
.result-card,
.modal-card {
  width: min(100%, 380px);
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 45%),
    rgba(8, 12, 22, 0.96);
  box-shadow: var(--shadow-md);
}

.countdown-card {
  width: auto;
  padding: 0;
  text-align: center;
  border: none;
  background: none;
  box-shadow: none;
}

.countdown-card__text {
  display: block;
  font-family: var(--font-main);
  font-size: clamp(3.6rem, 16vw, 5rem);
  color: #fef08a;
  text-shadow: 0 0 18px rgba(251, 191, 36, 0.42);
  transition: transform 0.16s ease, color 0.16s ease, text-shadow 0.16s ease;
}

.countdown-card__text[data-cue="go"] {
  color: #fca5a5;
  text-shadow: 0 0 20px rgba(248, 113, 113, 0.48);
  transform: scale(1.06);
}

.result-card,
.modal-card {
  padding: 22px;
}

.result-card {
  max-height: 100%;
  overflow: auto;
  display: grid;
  gap: 16px;
}

.result-card__summary,
.modal-message {
  color: var(--text-sub);
  line-height: 1.7;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.result-stat {
  padding: 12px 10px;
  border-radius: 16px;
  background: rgba(2, 6, 23, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.result-stat span {
  display: block;
  color: var(--text-soft);
  font-size: 0.72rem;
}

.result-stat strong {
  display: block;
  margin-top: 8px;
  font-family: var(--font-main);
  color: #fde68a;
  font-size: 1.1rem;
}

.result-history {
  display: grid;
  gap: 10px;
}

.result-card__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.result-history h4 {
  font-size: 0.95rem;
}

.history-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.history-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  background: rgba(2, 6, 23, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.history-item__badge {
  min-width: 72px;
  padding: 6px 10px;
  border-radius: 999px;
  text-align: center;
  font-size: 0.76rem;
  font-weight: 700;
}

.history-item__badge.hit {
  background: rgba(251, 191, 36, 0.16);
  color: #fde68a;
}

.history-item__badge.miss {
  background: rgba(248, 113, 113, 0.16);
  color: #fecaca;
}

.history-item__text {
  color: var(--text-sub);
  line-height: 1.5;
}

.history-empty {
  padding: 14px 0 4px;
  color: var(--text-soft);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  padding: 20px;
  display: grid;
  place-items: center;
  background: rgba(2, 6, 23, 0.7);
  z-index: 30;
}

.orientation-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding:
    max(20px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at top, rgba(239, 68, 68, 0.2), transparent 28%),
    rgba(1, 4, 10, 0.96);
}

.orientation-overlay__card {
  width: min(100%, 360px);
  display: grid;
  gap: 12px;
  padding: 24px 22px;
  text-align: center;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 45%),
    rgba(8, 12, 22, 0.96);
  box-shadow: var(--shadow-md);
}

.orientation-overlay__card h2 {
  font-size: 1.35rem;
  color: #ffffff;
}

.orientation-overlay__card p {
  color: var(--text-sub);
  line-height: 1.7;
}

.modal-card {
  width: min(100%, 420px);
  display: grid;
  gap: 16px;
}

.modal-card--compact {
  width: min(100%, 360px);
}

.faq-list {
  display: grid;
  gap: 14px;
}

.faq-item {
  padding: 14px;
  border-radius: 16px;
  background: rgba(2, 6, 23, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.faq-item h4 {
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.faq-item p {
  color: var(--text-sub);
  line-height: 1.7;
}

.modal-actions {
  justify-content: flex-end;
}

.is-hidden {
  display: none !important;
}

@keyframes marquee {
  from {
    transform: translate3d(0, 0, 0);
  }

  to {
    transform: translate3d(calc(var(--marquee-copy-width, 0px) * -1), 0, 0);
  }
}

@keyframes ledStream {
  from {
    background-position:
      50% 0,
      0 0,
      0 0,
      0 0,
      0 0,
      0 0,
      0 0;
  }

  to {
    background-position:
      50% 112px,
      0 0,
      0 0,
      0 15px,
      0 24px,
      0 112px,
      0 0;
  }
}

@keyframes ledPulse {
  0%,
  16%,
  34%,
  52%,
  100% {
    opacity: 0.98;
    filter: hue-rotate(0deg) saturate(1.35) brightness(1.08);
  }

  8%,
  24%,
  42%,
  68% {
    opacity: 0.86;
    filter: hue-rotate(55deg) saturate(1.7) brightness(1.24);
  }

  12%,
  29%,
  48%,
  78% {
    opacity: 1;
    filter: hue-rotate(120deg) saturate(2.05) brightness(1.46);
  }

  20%,
  38%,
  60%,
  88% {
    opacity: 0.92;
    filter: hue-rotate(210deg) saturate(1.82) brightness(1.3);
  }
}

@keyframes pushPulse {
  0%,
  100% {
    box-shadow:
      inset 0 -14px 18px rgba(69, 10, 10, 0.48),
      0 18px 24px rgba(0, 0, 0, 0.32);
  }

  50% {
    box-shadow:
      inset 0 -14px 18px rgba(69, 10, 10, 0.48),
      0 18px 24px rgba(0, 0, 0, 0.32),
      0 0 26px rgba(248, 113, 113, 0.28);
  }
}

@keyframes hitFlashRed {
  0%,
  100% {
    opacity: 0;
  }

  4%,
  8% {
    opacity: 1;
  }

  12%,
  18% {
    opacity: 0;
  }

  28%,
  34%,
  40%,
  46%,
  52% {
    opacity: 0.92;
  }

  31%,
  37%,
  43%,
  49%,
  55% {
    opacity: 0;
  }

  66% {
    opacity: 0.28;
  }

  74% {
    opacity: 1;
  }

  88% {
    opacity: 0.92;
  }

  96% {
    opacity: 0;
  }
}

@media (max-width: 720px) {
  :root {
    --page-pad-x: 0px;
    --page-pad-top: 0px;
    --page-pad-bottom: 0px;
    --machine-safe-top: max(var(--machine-safe-top-dynamic), env(safe-area-inset-top));
    --machine-safe-right: max(var(--machine-safe-right-dynamic), env(safe-area-inset-right));
    --machine-safe-bottom: max(var(--machine-safe-bottom-dynamic), env(safe-area-inset-bottom));
    --machine-safe-left: max(var(--machine-safe-left-dynamic), env(safe-area-inset-left));
  }

  body:not(.admin-page) {
    width: var(--viewport-width);
    min-height: var(--viewport-height);
    height: var(--viewport-height);
    padding: 0;
    overflow: hidden;
  }

  body:not(.admin-page) .app-shell {
    width: 100%;
    max-width: none;
    min-height: var(--viewport-height);
    height: var(--viewport-height);
    gap: 0;
  }

  body.admin-page .app-shell {
    grid-template-columns: 1fr;
  }

  body.admin-page .hero-card,
  body.admin-page .admin-settings-panel,
  body.admin-page .admin-preview-panel {
    grid-column: auto;
  }

  body.admin-page .admin-preview-panel {
    position: static;
    top: auto;
  }

  .two-column,
  .result-stats {
    grid-template-columns: 1fr;
  }

  .hero-card {
    display: none;
  }


  .admin-preview-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-preview-actions .secondary-button,
  .admin-preview-actions .ghost-button {
    width: 100%;
  }

  .game-stage {
    margin-inline: calc(50% - 50vw);
    min-height: var(--viewport-height);
    height: var(--viewport-height);
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  .stage-header {
    display: none;
  }

  .machine {
    width: var(--viewport-width);
    max-width: none;
    min-height: var(--viewport-height);
    height: var(--viewport-height);
    aspect-ratio: auto;
    border-radius: 0;
    border-inline: none;
    border-top-width: 0;
    border-bottom-width: 0;
    margin: 0;
  }

  .machine-safe {
    gap: var(--machine-ui-gap);
  }

  .machine-body {
    align-items: center;
  }

  .side-button {
    font-size: 1.45rem;
  }

  .history-item {
    grid-template-columns: 1fr;
  }

  .modal-card {
    padding: 18px;
  }

  .modal-backdrop {
    padding:
      max(18px, env(safe-area-inset-top))
      max(16px, env(safe-area-inset-right))
      max(18px, env(safe-area-inset-bottom))
      max(16px, env(safe-area-inset-left));
  }

  .entry-panel__card {
    width: min(100%, 390px);
  }

  .entry-logo-slot {
    min-height: 0;
  }

  .entry-best-card__stats {
    line-height: 1.5;
  }

}

body.desktop-preview-active:not(.admin-page) {
  width: var(--viewport-width);
  min-height: var(--viewport-height);
  height: var(--viewport-height);
  padding: var(--desktop-preview-padding);
  display: grid;
  place-items: center;
  overflow: auto;
}

body.desktop-preview-active:not(.admin-page) .app-shell {
  width: var(--app-frame-width);
  max-width: none;
  min-height: var(--app-frame-height);
  height: var(--app-frame-height);
  display: block;
  gap: 0;
}

body.desktop-preview-active:not(.admin-page) .hero-card,
body.desktop-preview-active:not(.admin-page) .stage-header {
  display: none;
}

body.desktop-preview-active:not(.admin-page) .game-stage {
  width: 100%;
  min-height: var(--app-frame-height);
  height: var(--app-frame-height);
  margin-inline: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

body.desktop-preview-active:not(.admin-page) .machine {
  width: 100%;
  max-width: none;
  min-height: var(--app-frame-height);
  height: var(--app-frame-height);
  aspect-ratio: auto;
  margin: 0;
  border-radius: 0;
  border-inline: none;
  border-top-width: 0;
  border-bottom-width: 0;
}

body.desktop-preview-active:not(.admin-page) .entry-panel {
  inset: var(--app-frame-top) auto auto var(--app-frame-left);
  width: var(--app-frame-width);
  height: var(--app-frame-height);
  padding: 0;
  transform: none;
  overflow: hidden;
}

body.desktop-preview-active:not(.admin-page) .entry-panel__card {
  width: 100%;
  max-width: none;
  min-height: 100%;
  height: 100%;
}

body.desktop-preview-active:not(.admin-page) .entry-marquee {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
}

body.desktop-preview-active:not(.admin-page) .control-row--entry {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--machine-safe-bottom);
}
