:root { --bg: #24324A; --card: #FFFFFF; --ink: #1E2533; --sub: #A9B4C7; --acc: #FFB347; --sel: #4FC3F7; --ok: #5CCB8B; --ng: #F26B6B; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Meiryo", sans-serif; background: var(--bg); color: #fff; display: flex; flex-direction: column; user-select: none; }
button { font: inherit; border: 0; border-radius: 14px; background: #34456A; color: #fff; padding: 10px 14px; min-height: 44px; cursor: pointer; }
button:disabled { opacity: .35; }
header { display: flex; align-items: center; gap: 8px; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); }
.title { font-weight: 800; font-size: 17px; letter-spacing: .02em; }
nav { flex: 1; display: flex; justify-content: center; gap: 6px; }
.tab { background: transparent; border: 1px solid #4A5D86; padding: 6px 12px; min-height: 36px; font-size: 14px; border-radius: 18px; }
.tab.on { background: var(--acc); color: #1E2533; border-color: var(--acc); font-weight: 700; }
.icon { width: 44px; padding: 0; font-size: 20px; background: transparent; }

main { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 6px 16px 20px; max-width: 520px; margin: 0 auto; width: 100%; }
#sub { color: var(--sub); font-size: 14px; min-height: 20px; }
.target { font-size: 64px; font-weight: 900; color: var(--acc); line-height: 1.1; margin: 4px 0 2px; }
#msg { color: var(--sub); font-size: 13.5px; min-height: 38px; text-align: center; line-height: 1.4; }
#tiles { display: flex; gap: 12px; justify-content: center; margin: 14px 0 22px; min-height: 104px; flex-wrap: wrap; }
.tile { width: 74px; min-height: 92px; border-radius: 18px; background: var(--card); color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 5px 0 #0003; transition: transform .12s; padding: 6px 4px; }
.tile .v { font-size: 38px; font-weight: 800; line-height: 1; }
.tile .v.small { font-size: 24px; }
.tile .e { font-size: 10.5px; color: #6B7487; margin-top: 6px; text-align: center; word-break: break-all; line-height: 1.25; }
.tile.sel { background: var(--sel); transform: translateY(-6px); }
.tile.hint { outline: 4px solid var(--acc); }
.tile.win { background: var(--ok); color: #fff; transform: scale(1.12); }
.tile.win .e { color: #fff; }
.tile.lose { background: var(--ng); color: #fff; animation: shake .4s; }
.tile.lose .e { color: #fff; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
#ops { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: 100%; max-width: 360px; }
#ops button { font-size: 30px; font-weight: 800; min-height: 64px; background: #3C5079; }
#ops button.on { background: var(--acc); color: #1E2533; }
#acts { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 10px; width: 100%; max-width: 360px; margin-top: 14px; }
#acts button { font-size: 15px; }
#btnHint { background: #5A4A86; }
#tix { font-size: 12px; opacity: .85; }
.rule { color: #7F8BA3; font-size: 12px; text-align: center; margin-top: 18px; line-height: 1.6; }

#shade { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 10; }
#sheet { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(92vw, 420px); max-height: 86vh; overflow: auto; background: #fff; color: var(--ink); border-radius: 20px; z-index: 11; padding: 22px 20px; text-align: center; }
#sheet h2 { margin: 0 0 10px; font-size: 22px; }
#sheet .big { font-size: 26px; font-weight: 800; margin: 10px 0; }
#sheet p { line-height: 1.7; margin: 8px 0; }
#sheet .note { color: #6B7487; font-size: 13px; }
#sheet .btns { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
#sheet .btns button { background: #E9EDF4; color: var(--ink); font-weight: 700; }
#sheet .btns button.pri { background: var(--acc); color: #1E2533; }
#sheet .grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; max-height: 50vh; overflow: auto; padding: 4px; }
#sheet .grid button { min-height: 40px; padding: 0; background: #E9EDF4; color: var(--ink); font-size: 13px; border-radius: 10px; }
#sheet .grid button.done { background: var(--ok); color: #fff; }
#sheet .grid button.cur { outline: 3px solid var(--acc); }
#sheet table { width: 100%; border-collapse: collapse; margin: 8px 0; }
#sheet td { padding: 8px 4px; border-bottom: 1px solid #EEF0F4; text-align: left; }
#sheet td:last-child { text-align: right; font-weight: 700; }
#toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: #111; color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 20; font-size: 14px; max-width: 90vw; }
.confetti { position: fixed; top: -10px; width: 9px; height: 14px; z-index: 9; animation: fall 1.6s linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); opacity: .6; } }
