:root {
  --bg: #fff9f7;
  --surface: #fffdfc;
  --surface-2: #fbeae7;
  --text: #8f504f;
  --muted: #9f8e8c;
  --gold: #d59b93;
  --gold-bright: #b66d6b;
  --green: #df9292;
  --green-hover: #d87e80;
  --gray: #dedddd;
  --red: #d84f4f;
  --red-bright: #ef6d67;
  --border: rgba(190, 124, 118, 0.36);
  --shadow: 0 16px 42px rgba(145, 92, 88, 0.15);
  font-family: "Arial Rounded MT Bold", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #fff3f1 url("./background-pink-simple.png") center top/cover fixed no-repeat; color: var(--text); }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 3px; }
[hidden] { display: none !important; }

.screen { min-height: 100vh; }
.home-screen { position: relative; isolation: isolate; container-type: inline-size; width: min(100vw,144.02vh); height: min(100vh,69.43vw); min-height: 0; margin: 0 auto; padding: 0; text-align: center; overflow: visible; background: transparent; }
.brand-mark { position: absolute; top: 4.5cqw; left: 25.2%; color: #c84f59; font-size: 2.25cqw; }
.home-title { position: absolute; z-index: 2; top: 6.52cqw; left: 50%; width: 47cqw; margin: 0; transform: translateX(-50%); }
.home-title img { display: block; width: 100%; height: auto; }
.mode-actions { position: absolute; top: 30.35cqw; left: 50%; display: grid; grid-template-columns: repeat(3,1fr); gap: 2.8%; width: 82%; height: 29.5cqw; transform: translateX(-50%); }
.mode-button { position: relative; width: 100%; min-height: 0; height: 100%; padding: 3.1cqw 2.5cqw 2.1cqw; border: 0; border-radius: 1.6cqw; background: transparent; cursor: pointer; box-shadow: none; color: inherit; }
.mode-button::before { content: ""; position: absolute; z-index: 0; inset: 0; background: url("./card-frame.png") center/100% 100% no-repeat; pointer-events: none; transform-origin: center; transition: transform .2s ease,filter .2s ease; }
.mode-button > * { position: relative; z-index: 1; }
.mode-button:hover { transform: none; color: inherit; }
.mode-button:hover::before { transform: scale(1.05); filter: brightness(1.28) saturate(1.12); }
.mode-button strong { display: block; color: #713b40; font: 900 3.05cqw/1.08 "Lantinghei SC","PingFang SC","Heiti SC",sans-serif; margin-bottom: .75cqw; }
.mode-button > span:last-child { display: inline-block; border-radius: 999px; padding: .42cqw 1.45cqw; background: #d99290; color: #fff; font: 800 1.7cqw "PingFang SC",system-ui,sans-serif; }
.bomb-art { position: relative; display: block; width: 11.5cqw; height: 14.2cqw; margin: 0 auto; }
.bomb-art img { position: absolute; width: 11.5cqw; height: 11.5cqw; object-fit: contain; left: 0; bottom: .15cqw; filter: drop-shadow(0 .6cqw .7cqw rgba(128,56,66,.16)); }
.double-bomb img:first-child { transform: translateX(-26px) rotate(-7deg) scale(.9); }
.double-bomb img:last-child { transform: translateX(28px) rotate(7deg) scale(.9); }
.mode-button-gold { background-color: transparent; }
.lucky-star-art { display: grid; place-items: center; width: 12.5cqw; height: 14.2cqw; margin: 0 auto; transform: translateY(-.25cqw); }
.lucky-star-art img { display: block; width: 12.5cqw; height: 12.5cqw; object-fit: contain; filter: drop-shadow(0 .55cqw .7cqw rgba(172,108,12,.22)); }
.lucky-mode-button strong { color: #9a6915; }
.lucky-mode-button > span:last-child { background: #e8b33b; }
.home-tools { position: absolute; z-index: 5; top: 62.2cqw; left: 50%; display: grid; grid-template-columns: repeat(3,15.5cqw); align-items: stretch; gap: 1cqw; width: max-content; margin: 0; transform: translateX(-50%); }
.text-button { min-width: 0; min-height: 4.7cqw; border: .14cqw solid #d99290; border-radius: .85cqw; padding: .65cqw .8cqw; background: rgba(255,253,252,.72); color: #8f504f; cursor: pointer; box-shadow: inset 0 0 0 .2cqw rgba(239,200,196,.42); font-size: 1.12cqw; font-weight: 800; white-space: nowrap; }
.text-button:hover { background: #f8dfdc; }
.audio-stack { display: grid; grid-template-rows: auto 1fr; align-items: center; gap: .2cqw; min-width: 0; min-height: 4.7cqw; border: .14cqw solid #d99290; border-radius: .85cqw; padding: .38cqw .65cqw .42cqw; background: rgba(255,253,252,.72); box-shadow: inset 0 0 0 .2cqw rgba(239,200,196,.42); }
.audio-stack > label { display: flex; align-items: center; justify-content: center; gap: 5px; color: #8f504f; font-size: .82cqw; font-weight: 800; }
.audio-stack input { width: 8.6cqw; height: 9px; accent-color: #d47778; cursor: pointer; }
.audio-stack output { min-width: 3em; text-align: right; }
.audio-stack .text-button { width: 100%; min-height: 0; border: 0; padding: .1cqw; background: transparent; box-shadow: none; font-size: 1.08cqw; }
.audio-stack .text-button:hover { background: transparent; color: #b85e62; }

.game-screen { height: 100dvh; min-height: 0; padding: 18px 22px 16px; overflow: hidden; display: grid; grid-template-rows: auto minmax(0,1fr); }
.game-header { max-width: 1480px; margin: 0 auto 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.title-lockup { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.title-lockup span { color: var(--gold); }
.title-lockup h1 { margin: 0; font-size: 32px; letter-spacing: .04em; }
.single-rule-selector { display: flex; align-items: center; gap: 4px; padding: 4px; border: 1px solid #e8c2bd; border-radius: 9px; background: rgba(255,249,248,.88); box-shadow: 0 4px 11px rgba(145,92,88,.08); white-space: nowrap; }
.single-rule-selector .rule-button { min-height: 32px; border: 1px solid transparent; border-radius: 7px; padding: 5px 10px; background: transparent; color: #a45f5d; font: 800 12px "Arial Rounded MT Bold","PingFang SC",system-ui,sans-serif; cursor: pointer; }
.single-rule-selector .rule-button:hover:not(:disabled) { border-color: #e5a7a4; background: #fbe7e4; }
.single-rule-selector .rule-button.active { border-color: #d77f7e; background: linear-gradient(180deg,#e9aaa7,#da8888); color: #fff; box-shadow: 0 3px 8px rgba(177,91,91,.2); }
.single-rule-selector.locked { opacity: .68; }
.single-rule-selector .rule-button:disabled { cursor: default; }
.game-controls { display: grid; grid-template-columns: repeat(4,106px); justify-content: end; align-items: stretch; gap: 5px; }
.game-controls > button, .status-control { width: 106px; min-height: 50px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid #e8c2bd; border-radius: 8px; background: #fff9f8; color: #a45f5d; padding: 6px 8px; font: 700 12px "Arial Rounded MT Bold", "PingFang SC", system-ui,sans-serif; box-shadow: 0 4px 11px rgba(145,92,88,.08); white-space: nowrap; }
.game-audio { width: 106px; min-width: 0; min-height: 50px; gap: 1px; border-width: 1px; border-radius: 8px; padding: 4px 6px; box-shadow: 0 4px 11px rgba(145,92,88,.08); }
.game-audio > label { font-size: 10px; }
.game-audio input { width: 58px; }
.game-audio button { width: 100%; min-height: 22px; border: 0; outline: 0; padding: 1px; background: transparent; color: #a45f5d; box-shadow: none; font: 700 12px "Arial Rounded MT Bold","PingFang SC",system-ui,sans-serif; cursor: pointer; }
.game-audio button:hover { border: 0; background: transparent; color: #b85e62; }
.game-audio button:focus-visible { outline: 2px solid rgba(212,119,120,.6); outline-offset: 1px; border-radius: 4px; }
.game-controls button { cursor: pointer; }
.game-controls button:hover { border-color: var(--gold-bright); background: #f8d9d5; }
#bomb-count { color: var(--gold-bright); }
.game-layout { width: 100%; height: 100%; min-height: 0; max-width: 1480px; margin: auto; display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 12px; align-items: stretch; }
.game-screen[data-mode="single"] .game-layout { grid-template-columns: 1fr; }
.game-screen[data-mode="single"] .punishment-rail { display: none; }
.game-screen[data-mode="lucky"] .game-layout { grid-template-columns: 1fr; }
.game-screen[data-mode="lucky"] .punishment-rail { display: none; }
.board-panel { height: 100%; min-height: 0; border: 1px solid var(--border); border-radius: 14px; padding: 14px; background: rgba(255, 253, 252, .9); box-shadow: var(--shadow); }
.number-board { height: 100%; min-height: 0; display: grid; grid-template-columns: repeat(10, minmax(44px, 1fr)); grid-template-rows: repeat(10,minmax(0,1fr)); gap: 7px; }
.number-tile { min-width: 0; min-height: 0; border: 1px solid #d98686; border-radius: 8px; background: linear-gradient(145deg, #e7a2a0, #d98889); color: #fffdf8; font-family: "Arial Rounded MT Bold", "PingFang SC", system-ui, sans-serif; font-size: clamp(20px, min(2.15vw,3.3vh), 32px); font-weight: 800; text-shadow: 0 1px 1px rgba(126,67,65,.25); cursor: pointer; box-shadow: inset 0 1px rgba(255,255,255,.35), 0 2px 5px rgba(151,93,89,.08); transition: transform .12s, background .2s, opacity .2s; }
.number-tile:hover { transform: translateY(-2px); background: var(--green-hover); }
.number-tile.gray { border-color: #d0cece; background: var(--gray); color: #777; cursor: default; opacity: .72; text-shadow: none; transform: none; }
.number-tile.red { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; border-color: #ff7d69; background: radial-gradient(circle, var(--red-bright), var(--red) 65%); animation: bomb-pop .48s ease both; box-shadow: 0 0 26px rgba(240, 91, 73, .5); cursor: default; font-size: clamp(14px, 1.3vw, 20px); line-height: 1; }
.number-tile.red::before { content: "💣"; display: block; font-size: clamp(18px, 2vw, 29px); line-height: 1; filter: drop-shadow(0 2px 2px rgba(100,20,20,.25)); }
.number-tile.lucky { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; border-color: #e2ae27; background: radial-gradient(circle at 35% 30%,#fff2a6,#f5c739 58%,#dfa514); color: #8c5b08; animation: bomb-pop .48s ease both; box-shadow: 0 0 28px rgba(245,190,48,.55); cursor: default; font-size: clamp(14px,1.3vw,20px); line-height: 1; }
.number-tile.lucky::before { content: ""; display: block; width: clamp(22px,2.5vw,36px); height: clamp(22px,2.5vw,36px); background: url("./lucky-star.png") center/contain no-repeat; filter: drop-shadow(0 2px 2px rgba(154,99,4,.3)); }
.number-tile.turning-gray { animation: fade-gray .18s ease both; }
@keyframes fade-gray { 50% { transform: scale(.82); } }
@keyframes bomb-pop { 0% { transform: scale(.55) rotate(-8deg); } 60% { transform: scale(1.18) rotate(3deg); } 100% { transform: scale(1); } }
.punishment-rail { min-height: 0; border: 1px solid var(--border); border-radius: 11px; padding: 10px; background: rgba(255,253,252,.86); box-shadow: 0 8px 24px rgba(145,92,88,.1); }
.punishment-rail h2 { margin: 0 0 9px; color: var(--gold-bright); text-align: center; font-size: 17px; }
.side-punishments { display: grid; gap: 8px; }
.rail-empty { color: var(--muted); font: 13px/1.45 system-ui,sans-serif; text-align: center; margin: 12px 4px; }
.side-card { border-top: 3px solid var(--red); background: var(--surface-2); padding: 9px 8px; border-radius: 7px; }
.side-card h3 { margin: 0 0 6px; color: var(--gold-bright); font-size: 14px; }
.side-card p { margin: 0; font: 600 14px/1.45 system-ui,sans-serif; }
.game-hint { max-width: 1480px; margin: 12px auto 0; color: var(--muted); text-align: center; font: 14px system-ui, sans-serif; }

.modal { width: min(92vw, 610px); border: 1px solid var(--border); border-radius: 15px; background: rgba(255,253,252,.98); color: var(--text); box-shadow: 0 30px 90px rgba(113,67,64,.35); padding: 30px; }
.modal::backdrop { background: rgba(255, 232, 230, .42); backdrop-filter: blur(2px); }
.bomb-modal { width: min(94vw,780px); padding: 42px 38px 36px; text-align: center; overflow: visible; }
.bomb-modal h2 { margin: 0; font-size: clamp(36px,4.6vw,58px); }
.punishment-order { margin: 0 auto 24px; color: var(--gold-bright); font-size: 28px; font-weight: 800; }
.punishment-text { min-height: 190px; display: grid; place-items: center; margin: 0; padding: 34px 28px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: transparent; border-radius: 0; font: 800 clamp(32px,3.8vw,52px)/1.45 "Arial Rounded MT Bold", "PingFang SC", system-ui,sans-serif; }
.modal-actions { display: flex; justify-content: center; gap: 12px; margin-top: 22px; }
.primary-button, .secondary-button, .danger-button, .icon-button { border-radius: 7px; padding: 11px 18px; cursor: pointer; }
.primary-button { border: 1px solid #d97f7e; background: linear-gradient(180deg, #e79b99, #d97e7f); color: white; }
.secondary-button { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.danger-button { border: 1px solid #d26359; background: transparent; color: #ff9487; }
.icon-button { border: 0; background: transparent; font-size: 30px; }
.manager-modal { width: min(94vw, 760px); text-align: left; }
.manager-header { display: flex; justify-content: space-between; gap: 20px; align-items: start; }
.manager-header h2 { margin: 0 0 7px; font-size: 30px; }
.manager-header p { margin: 0; color: var(--muted); font: 14px system-ui, sans-serif; }
.add-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin: 22px 0 15px; }
.add-form input { min-width: 0; border: 1px solid var(--border); border-radius: 7px; padding: 12px; background: #fffafa; color: var(--text); font: 16px system-ui, sans-serif; }
.punishment-list { max-height: 50vh; overflow: auto; display: grid; gap: 8px; padding-right: 5px; }
.punishment-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; align-items: center; padding: 10px; border: 1px solid rgba(205,164,92,.25); border-radius: 7px; background: rgba(255,255,255,.025); }
.punishment-row input[type="text"] { min-width: 0; border: 0; border-bottom: 1px solid transparent; background: transparent; color: var(--text); padding: 6px; font: 15px system-ui, sans-serif; }
.punishment-row input[type="text"]:focus { border-color: var(--gold); }
.row-action { border: 0; background: transparent; color: var(--gold-bright); cursor: pointer; font: 14px system-ui, sans-serif; }
.row-action.delete { color: #ff897c; }
.manager-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.file-button { display: inline-flex; align-items: center; cursor: pointer; }
.file-button input { display: none; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 20; padding: 11px 18px; border: 1px solid var(--border); border-radius: 8px; background: #0e2232; opacity: 0; pointer-events: none; transition: .2s; font: 15px system-ui, sans-serif; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .game-header { align-items: flex-start; flex-wrap: wrap; }
  .single-rule-selector { order: 3; margin: -5px auto 0; }
  .title-lockup h1 { font-size: 30px; }
  .game-layout { grid-template-columns: 1fr; grid-template-rows: minmax(0,1fr) auto; }
  .punishment-rail { min-height: auto; }
  .rail-empty { margin: 16px 0; }
  .side-punishments { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .number-board { gap: 5px; }
}
@media (max-width: 680px) {
  .home-screen { width: 100vw; height: 116vw; }
  .home-title { top: 7vw; width: 70vw; }
  .brand-mark { top: 5vw; font-size: 4vw; }
  .mode-actions { top: 45vw; width: 92vw; height: 48vw; gap: 3vw; }
  .mode-button { padding: 4vw 3vw 2.5vw; }
  .bomb-art { width: 17vw; height: 21vw; }
  .bomb-art img { width: 17vw; height: 17vw; }
  .lucky-star-art { width: 17vw; height: 21vw; }
  .lucky-star-art img { width: 17vw; height: 17vw; }
  .mode-button strong { font-size: 4vw; margin-bottom: 1vw; }
  .mode-button > span:last-child { padding: .8vw 2vw; font-size: 2.8vw; }
  .double-bomb img:first-child { transform: translateX(-3.4vw) rotate(-7deg) scale(.9); }
  .double-bomb img:last-child { transform: translateX(3.6vw) rotate(7deg) scale(.9); }
  .home-tools { top: 97vw; left: 2vw; grid-template-columns: repeat(3,minmax(0,1fr)); width: 96vw; gap: 5px; transform: none; padding: 2px; }
  .text-button { min-width: 0; min-height: 50px; border-width: 1px; border-radius: 7px; padding: 7px 4px; box-shadow: none; font-size: 10px; }
  .audio-stack { min-width: 0; min-height: 50px; gap: 2px; border-width: 1px; border-radius: 7px; padding: 4px; box-shadow: none; }
  .audio-stack > label { gap: 2px; font-size: 9px; }
  .audio-stack input { width: 48px; height: 9px; }
  .home-tools #music-home { font-size: 13px; }
  .game-screen { padding: 10px 8px; }
  .game-header { display: block; }
  .title-lockup { justify-content: center; margin-bottom: 10px; }
  .title-lockup h1 { font-size: 24px; }
  .game-controls { grid-template-columns: repeat(4,84px); width: max-content; max-width: 100%; justify-content: center; gap: 5px; margin: 0 auto; overflow: visible; padding: 2px 0 8px; }
  .single-rule-selector { width: max-content; margin: 0 auto 8px; }
  .single-rule-selector .rule-button { min-height: 31px; padding: 4px 9px; font-size: 11px; }
  .game-controls > button, .status-control { width: 84px; min-height: 43px; padding: 4px; font-size: 10px; }
  .game-audio { width: 84px; min-width: 84px; min-height: 43px; padding: 3px 4px; }
  .game-audio > label { font-size: 9px; }
  .game-audio input { width: 43px; }
  .game-audio button { min-height: 18px; font-size: 10px; }
  .board-panel { padding: 7px; }
  .number-board { grid-template-columns: repeat(10,minmax(0,1fr)); gap: 3px; }
  .number-tile { min-width: 0; min-height: 27px; border-radius: 4px; font-size: clamp(11px,3.6vw,17px); }
  .punishment-rail { padding: 13px; }
  .modal { padding: 22px 16px; }
  .bomb-modal h2 { font-size: 34px; }
  .punishment-text { font-size: 20px; }
  .punishment-row { grid-template-columns: auto 1fr auto; }
  .punishment-row .delete { grid-column: 3; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
