@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Silkscreen:wght@400;700&family=VT323&display=swap');

@font-face {
  font-family: 'Zpix';
  src: url('https://cdn.jsdelivr.net/gh/SolidZORO/zpix-pixel-font@main/dist/zpix.ttf') format('truetype');
  font-display: swap;
}

* {
  margin: 0; padding: 0; box-sizing: border-box;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  image-rendering: pixelated;
}

html, body { height: 100%; overflow: hidden; }

body {
  background:
    radial-gradient(ellipse at top, #1a1008 0%, #0f0a04 60%, #060402 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Zpix', 'Silkscreen', 'Press Start 2P', 'VT323', monospace;
  color: #f5e6d0;
  padding: 8px 0;
  position: relative;
}

body::before {
  content:'';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(212,168,75,0.05), transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(196,120,91,0.04), transparent 45%),
    repeating-linear-gradient(90deg, rgba(212,168,75,0.02) 1px, transparent 1px, transparent 10px),
    repeating-linear-gradient(0deg, rgba(212,168,75,0.02) 1px, transparent 1px, transparent 10px);
  animation: ambient 16s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}
@keyframes ambient {
  0%   { transform: translate(0,0); opacity: 1; }
  100% { transform: translate(-18px, 12px); opacity: 0.85; }
}

.machine {
  width: 500px;
  max-width: 96vw;
  height: calc(100vh - 20px);
  max-height: 840px;
  background: linear-gradient(180deg, #2d1810 0%, #231208 50%, #1a0f08 100%);
  padding: 14px 18px 16px;
  position: relative;
  display: flex;
  flex-direction: column;
  z-index: 1;
  box-shadow:
    0 0 0 2px #5a3a20,
    0 0 0 6px #0a0604,
    0 0 0 8px #7a5230,
    0 0 0 12px #0a0604,
    0 0 0 13px rgba(212,168,75,0.25),
    8px 10px 0 0 rgba(0,0,0,0.55);
}

.machine-label {
  text-align: center;
  color: #e8b84b;
  font-family: 'Silkscreen', 'Press Start 2P', monospace;
  font-size: 10px;
  letter-spacing: 3px;
  margin-bottom: 4px;
  text-transform: uppercase;
  flex: 0 0 auto;
  text-shadow: 0 0 8px rgba(212,168,75,0.35);
}

.machine-sublabel {
  text-align: center;
  color: #8a6a42;
  font-family: 'Silkscreen', 'Press Start 2P', monospace;
  font-size: 7px;
  letter-spacing: 2px;
  margin-bottom: 10px;
  flex: 0 0 auto;
}

.screen-bezel {
  background: #060402;
  padding: 8px;
  margin-bottom: 12px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  box-shadow:
    inset 0 0 0 2px #000,
    inset 0 0 0 4px #0a0604,
    0 0 0 2px #5a3a20,
    0 0 0 3px rgba(212,168,75,0.28);
}

.screen {
  background:
    radial-gradient(ellipse at 50% 0%, #1a1408 0%, #140f06 30%, #0f0a04 60%, #060402 100%);
  padding: 12px 14px;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  color: #f5e6d0;
  font-family: 'Zpix', 'VT323', monospace;
  font-size: 14px;
  line-height: 1.55;
  scrollbar-width: thin;
  scrollbar-color: #e8b84b transparent;
}
.screen::-webkit-scrollbar { width: 4px; }
.screen::-webkit-scrollbar-track { background: transparent; }
.screen::-webkit-scrollbar-thumb { background: #e8b84b; border-radius: 0; }

@media (max-width: 420px) {
  .screen { padding: 10px 12px; font-size: 13px; }
}

@media (max-height: 640px) {
  .screen { font-size: 12px; line-height: 1.45; }
  .machine-sublabel { display: none; }
}

.screen::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.18) 0px,
    rgba(0,0,0,0.18) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 1;
}

.screen::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse at 50% 30%, transparent 55%, rgba(0,0,0,0.45) 100%),
    linear-gradient(180deg, rgba(212,168,75,0.03) 0%, transparent 40%);
  pointer-events: none;
  z-index: 2;
}

.screen > * { position: relative; z-index: 3; }

.stats-bar {
  display: flex;
  justify-content: space-between;
  font-family: 'Silkscreen', 'Press Start 2P', 'Zpix', monospace;
  font-size: 9px;
  color: #c4a882;
  border-bottom: 2px dotted #6a4a28;
  padding-bottom: 6px;
  margin-bottom: 6px;
  letter-spacing: 1px;
}
.stats-bar span { white-space: nowrap; }
.stats-bar b { color: #e8b84b; font-weight: normal; margin-left: 2px; }

.practice-hud {
  font-family: 'Silkscreen', 'Press Start 2P', 'Zpix', monospace;
  font-size: 9px;
  color: #c4a882;
  border-bottom: 1px dashed rgba(212,168,75,0.28);
  padding: 4px 0 5px;
  margin-bottom: 6px;
  letter-spacing: 1px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 10px;
}

.practice-hud .label { color: #8a6a42; }
.practice-hud .val { color: #f5e6d0; }
.practice-hud .danger { color: #e85d5d; animation: blink 0.7s steps(2) infinite; }
.practice-hud .warn { color: #f5a623; }
.practice-hud .good { color: #7bc88f; }

.bar {
  display: inline-block;
  font-family: monospace;
  letter-spacing: -1px;
  color: #e8b84b;
}

.title-art {
  text-align: center;
  margin: 10px 0 6px;
  font-size: 13px;
  line-height: 1.5;
  color: #f5e6d0;
}

.title-art .big {
  font-size: 26px;
  letter-spacing: 8px;
  margin: 12px 0 8px;
  color: #e8c171;
  text-shadow:
    2px 0 0 #8a5a20,
    0 2px 0 #8a5a20,
    2px 2px 0 #8a5a20,
    0 0 12px rgba(212,168,75,0.4);
  animation: titleGlow 3s ease-in-out infinite;
}
@keyframes titleGlow {
  0%,100% { text-shadow: 2px 0 0 #8a5a20, 0 2px 0 #8a5a20, 2px 2px 0 #8a5a20, 0 0 8px rgba(212,168,75,0.25); }
  50%     { text-shadow: 2px 0 0 #8a5a20, 0 2px 0 #8a5a20, 2px 2px 0 #8a5a20, 0 0 24px rgba(212,168,75,0.65); }
}

.title-art svg { display: block; margin: 0 auto; }

.hero-img {
  display: block;
  margin: 8px auto;
  width: 80%;
  max-width: 320px;
  height: auto;
  border: 2px solid #5a3a20;
  box-shadow: 0 0 12px rgba(212,168,75,0.2);
  image-rendering: auto;
}

.scene-title {
  text-align: center;
  margin: 3px 0;
  font-size: 13px;
  color: #e8b84b;
}

.scene-flavor {
  text-align: center;
  font-size: 12px;
  color: #8a6a42;
  margin-bottom: 5px;
}

.narrative {
  margin: 5px 0 6px;
  font-size: 13px;
  line-height: 1.55;
}

.divider {
  text-align: center;
  color: #6a4a2840;
  margin: 3px 0;
  font-size: 11px;
  letter-spacing: 2px;
}

.choice {
  margin: 3px 0;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 7px;
  line-height: 1.4;
  color: #f5e6d0;
  border-left: 2px solid transparent;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.choice:hover {
  color: #e8c171;
  border-left-color: #e8b84b;
  background: rgba(212,168,75,0.08);
}

.choice.selected {
  color: #1a0e00;
  background: linear-gradient(90deg, #e8b84b 0%, #e8c171 100%);
  border-left-color: #e8c171;
  box-shadow: 0 0 10px rgba(212,168,75,0.45);
}

.choice .key {
  display: inline-block;
  width: 20px;
  color: inherit;
}

.choice .tag {
  display: inline;
  font-size: 10px;
  color: #8a6a42;
  margin-left: 8px;
  white-space: nowrap;
}

.choice.selected .tag { color: #3a2a0e; }

.result-text {
  margin: 5px 0;
  font-size: 13px;
  line-height: 1.55;
}

.result-text .gain { color: #7bc88f; }
.result-text .lose { color: #e85d5d; }
.result-text .event { color: #c4a882; }
.result-text .item { color: #c490d1; }
.result-text .reckless { color: #f5a623; }

.prompt {
  text-align: center;
  font-family: 'Press Start 2P', 'Zpix', monospace;
  font-size: 9px;
  color: #8a6a42;
  margin-top: 8px;
  letter-spacing: 1px;
  animation: blink 1s steps(2) infinite;
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px;
  flex: 0 0 auto;
}

.dpad {
  display: grid;
  grid-template-columns: 36px 36px 36px;
  grid-template-rows: 36px 36px 36px;
  gap: 0;
}

.dpad-btn {
  width: 36px;
  height: 36px;
  background: #1a0f08;
  border: 0;
  color: #f5e6d0;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  box-shadow:
    inset 2px 2px 0 0 #5a3a20,
    inset -2px -2px 0 0 #000;
}

.dpad-btn:active {
  background: #0a0604;
  box-shadow:
    inset -2px -2px 0 0 #5a3a20,
    inset 2px 2px 0 0 #000;
}

.dpad-btn.empty { background: transparent; box-shadow: none; visibility: hidden; }
.dpad-btn.ok { font-family: 'Press Start 2P', monospace; font-size: 9px; letter-spacing: 1px; color: #e8c171; }

.ab-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.ab-btn {
  width: 46px;
  height: 46px;
  border: 0;
  font-family: 'Press Start 2P', monospace;
  font-size: 16px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  clip-path: polygon(
    25% 0%, 75% 0%,
    100% 25%, 100% 75%,
    75% 100%, 25% 100%,
    0% 75%, 0% 25%
  );
}

.ab-btn:active { transform: translate(1px, 1px); }

.ab-btn.btn-a {
  background: #e8b84b;
  color: #fff;
  box-shadow: inset 0 -6px 0 0 #8a5a20;
}

.ab-btn.btn-b {
  background: #7a5230;
  color: #fff;
  box-shadow: inset 0 -6px 0 0 #3a2210;
}

.btn-label {
  font-family: 'Press Start 2P', 'Zpix', monospace;
  font-size: 7px;
  color: #6a4a28;
  text-align: center;
  margin-top: 4px;
  letter-spacing: 1px;
}

.footer-info {
  text-align: center;
  font-family: 'Press Start 2P', 'Zpix', monospace;
  color: #3a2210;
  font-size: 7px;
  margin-top: 10px;
  letter-spacing: 2px;
  flex: 0 0 auto;
}

.cert-up {
  text-align: center;
  font-family: 'Press Start 2P', 'Zpix', monospace;
  font-size: 13px;
  color: #e8c171;
  margin: 8px 0;
  letter-spacing: 2px;
  animation: pixelblink 0.5s steps(2) infinite;
  text-shadow:
    2px 0 0 #8a5a20,
    0 2px 0 #8a5a20,
    2px 2px 0 #8a5a20;
}

@keyframes pixelblink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.4; }
}

.battle-stats {
  font-size: 12px;
  margin: 8px 0;
  line-height: 1.6;
  color: #e8b84b;
}

.ending-title {
  text-align: center;
  font-family: 'Press Start 2P', 'Zpix', monospace;
  font-size: 15px;
  margin: 8px 0 6px;
  letter-spacing: 3px;
  color: #e8c171;
  text-shadow:
    2px 0 0 #8a5a20,
    0 2px 0 #8a5a20,
    2px 2px 0 #8a5a20;
}

.ending-summary {
  font-size: 12px;
  line-height: 1.55;
  margin: 6px 0;
}

.items-list {
  font-size: 11px;
  color: #c490d1;
  margin: 6px 0;
  line-height: 1.6;
}

.pixel-art {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 4px 0 6px;
  min-height: 40px;
}

.pixel-art svg {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.notes-bg {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.music-note {
  position: absolute;
  font-size: 14px;
  color: rgba(212,168,75,0.25);
  animation: noterise linear infinite;
  user-select: none;
}

@keyframes noterise {
  0% { bottom: -20px; opacity: 0; transform: rotate(0deg); }
  15% { opacity: 0.6; }
  85% { opacity: 0.4; }
  100% { bottom: 110%; opacity: 0; transform: rotate(20deg); }
}

.wave-line {
  color: #6a4a28;
  font-family: monospace;
  text-align: center;
  font-size: 10px;
  letter-spacing: 0;
}

/* ========== 姓名输入 ========== */
.name-input-wrap {
  margin: 12px auto;
  padding: 10px 14px;
  border: 2px solid #e8b84b;
  background: rgba(10,6,4,0.6);
  max-width: 300px;
  min-height: 44px;
  position: relative;
  box-shadow:
    0 0 14px rgba(212,168,75,0.25),
    inset 0 0 8px rgba(212,168,75,0.08);
}
.name-input-wrap::before, .name-input-wrap::after {
  content:''; position:absolute;
  width: 10px; height: 10px;
  background: #e8b84b;
}
.name-input-wrap::before { top: -2px; left: -2px; }
.name-input-wrap::after { bottom: -2px; right: -2px; }

#name-text {
  width: 100%;
  background: transparent;
  border: 0;
  outline: 0;
  color: #e8c171;
  font-family: 'Zpix', 'Press Start 2P', 'VT323', monospace;
  font-size: 20px;
  letter-spacing: 3px;
  text-align: center;
  -webkit-appearance: none;
  appearance: none;
  image-rendering: pixelated;
  caret-color: #e8b84b;
  padding: 4px 0;
}
#name-text::placeholder { color: #5a3a20; letter-spacing: 2px; font-size: 15px; }
#name-text:focus { color: #e8c171; }

.quick-names {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
  margin: 8px 0 4px;
}
.quick-name {
  padding: 4px 10px;
  background: rgba(212,168,75,0.08);
  border: 1px solid rgba(212,168,75,0.35);
  color: #e8c171;
  font-size: 11px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.15s;
}
.quick-name:hover { background: rgba(212,168,75,0.2); color: #e8c171; }

/* ========== 结算页 ========== */
.ending-wrap { position: relative; }
.ending-frame {
  margin: 6px 0;
  padding: 8px 10px;
  border: 1px solid rgba(212,168,75,0.35);
  background: rgba(10,6,4,0.4);
  position: relative;
}
.ending-frame::before, .ending-frame::after {
  content:''; position: absolute;
  width: 8px; height: 8px;
  background: #e8b84b;
}
.ending-frame::before { top: -2px; left: -2px; }
.ending-frame::after  { bottom: -2px; right: -2px; }

.diver-name-line {
  text-align: center;
  font-size: 16px;
  color: #e8c171;
  letter-spacing: 4px;
  margin: 4px 0;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(212,168,75,0.5);
}

.fun-title {
  text-align: center;
  font-size: 14px;
  color: #c4785b;
  letter-spacing: 2px;
  margin: 6px 0 4px;
  padding: 6px 0;
  background: rgba(196,120,91,0.1);
  border-top: 1px dashed #c4785b;
  border-bottom: 1px dashed #c4785b;
}

.data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  margin: 6px 0;
}
.data-cell {
  padding: 5px 6px;
  background: rgba(10,6,4,0.5);
  border: 1px solid rgba(212,168,75,0.2);
  text-align: center;
}
.data-cell .data-label {
  color: #8a6a42;
  font-size: 9px;
  letter-spacing: 1px;
  margin-bottom: 2px;
  display: block;
  font-family: 'Silkscreen', 'Press Start 2P', 'Zpix', monospace;
}
.data-cell .data-value {
  color: #e8c171;
  font-size: 15px;
  font-weight: bold;
}

.fun-fact {
  background: rgba(123,200,143,0.08);
  border-left: 3px solid #7bc88f;
  padding: 5px 8px;
  margin: 3px 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: #f5e6d0;
}
.fun-fact b { color: #7bc88f; }

.achievement-row {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin: 6px 0; justify-content: center;
}
.achievement {
  padding: 3px 8px;
  font-size: 10px;
  background: rgba(196,144,209,0.15);
  border: 1px solid #c490d1;
  color: #c490d1;
  letter-spacing: 1px;
}

.quip {
  text-align: center;
  font-size: 12px;
  color: #e8c171;
  margin: 8px 0;
  padding: 8px;
  background: rgba(212,168,75,0.06);
  border-left: 2px solid #e8b84b;
  border-right: 2px solid #e8b84b;
  line-height: 1.55;
}
.quip::before { content: '\300C '; color: #e8b84b; }
.quip::after  { content: ' \300D'; color: #e8b84b; }

.download-zone {
  margin: 18px auto 8px;
  padding: 14px 10px 12px;
  border: 2px dashed #e8b84b;
  background: linear-gradient(180deg, rgba(212,168,75,0.18) 0%, rgba(212,168,75,0.05) 100%);
  text-align: center;
  position: relative;
}
.download-zone::before, .download-zone::after {
  content: '';
  position: absolute;
  top: -2px;
  width: 20px;
  height: 2px;
  background: #1a0f08;
}
.download-zone::before { left: 30%; }
.download-zone::after { right: 30%; }
.download-zone-hint {
  color: #e8c171;
  font-family: 'Silkscreen', 'Press Start 2P', 'Zpix', monospace;
  font-size: 14px;
  letter-spacing: 4px;
  margin-bottom: 10px;
  text-shadow: 0 0 10px rgba(212,168,75,0.6);
  animation: labelPulse 1.2s ease-in-out infinite;
}
@keyframes labelPulse {
  0%,100% { opacity: 1; text-shadow: 0 0 8px rgba(212,168,75,0.4); }
  50%     { opacity: 1; text-shadow: 0 0 22px rgba(212,168,75,0.9); }
}

.share-btn {
  display: block;
  width: 94%;
  max-width: 360px;
  margin: 4px auto;
  padding: 18px 0;
  background: linear-gradient(180deg, #e8c171 0%, #e8b84b 50%, #c4785b 100%);
  color: #1a0e00;
  border: 0;
  font-family: 'Silkscreen', 'Press Start 2P', 'Zpix', monospace;
  font-size: 15px;
  letter-spacing: 5px;
  font-weight: bold;
  cursor: pointer;
  clip-path: polygon(4% 0,96% 0,100% 50%,96% 100%,4% 100%,0 50%);
  box-shadow:
    inset 0 -7px 0 0 #8a5a20,
    0 0 28px rgba(212,168,75,0.75);
  animation: sharePulse 1.6s ease-in-out infinite;
  position: relative;
  text-shadow: 1px 1px 0 rgba(255,255,255,0.25);
}
.share-btn:active { transform: translate(1px, 2px); box-shadow: inset 0 -5px 0 0 #8a5a20, 0 0 18px rgba(212,168,75,0.5); }
.share-btn:disabled { opacity: 0.6; cursor: not-allowed; animation: none; }
@keyframes sharePulse {
  0%,100% { box-shadow: inset 0 -7px 0 0 #8a5a20, 0 0 22px rgba(212,168,75,0.55); }
  50%     { box-shadow: inset 0 -7px 0 0 #8a5a20, 0 0 52px rgba(212,168,75,1); }
}

.ab-hint {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 10px 4px 6px;
  font-family: 'Silkscreen', 'Press Start 2P', 'Zpix', monospace;
  font-size: 11px;
  letter-spacing: 2px;
}
.ab-hint-a {
  padding: 6px 14px;
  background: rgba(212,168,75,0.2);
  border: 1px solid #e8b84b;
  color: #e8c171;
}
.ab-hint-b {
  padding: 6px 14px;
  background: rgba(122,82,48,0.2);
  border: 1px solid #7a5230;
  color: #c4a882;
}
.share-hint {
  text-align: center;
  font-size: 10px;
  color: #c4a882;
  margin: 2px 0 8px;
  letter-spacing: 1px;
}
