@font-face{font-family:CrystalKorean;src:url('assets/fonts/korean-400.woff2') format('woff2');font-weight:400;font-display:swap}@font-face{font-family:CrystalKorean;src:url('assets/fonts/korean-700.woff2') format('woff2');font-weight:700;font-display:swap}
:root{color-scheme:dark;--cream:#fff1d2;--muted:#d3b990;--gold:#f9d16d;--line:#ab815342;--panel:#26180deb}*{box-sizing:border-box}body{margin:0;background:#472712 url(assets/oak.jpg) repeat;color:var(--cream);font-family:CrystalKorean,'Malgun Gothic','Apple SD Gothic Neo',system-ui,sans-serif;font-size:15px}body:before{content:'';position:fixed;inset:0;pointer-events:none;background:radial-gradient(ellipse at 40% 25%,transparent,#100a0666)}button,select,input{font:inherit}button,select{border:1px solid #bd92535c;color:var(--cream);border-radius:12px;background:linear-gradient(#73502b38,#21120875);padding:11px 14px;cursor:pointer;min-height:44px;display:inline-flex;gap:9px;align-items:center;justify-content:center;transition:background .16s,transform .16s,box-shadow .16s}button:hover:not(:disabled){background:#8b622b75;box-shadow:0 0 0 1px #f1c77980}button:active:not(:disabled){transform:translateY(1px)}button:focus-visible,select:focus-visible,input:focus-visible{outline:3px solid #99e9d3;outline-offset:3px}button:disabled{opacity:.38;cursor:default}button.active{border-color:var(--gold);background:#c8a35925;box-shadow:inset 0 0 0 1px #f9d16d50}button.primary{background:linear-gradient(145deg,#fff8e6,#ddc497);color:#34210f;border-color:#ffdf99;font-weight:800;font-size:19px;min-height:59px;margin-top:20px;width:100%;box-shadow:0 5px 16px #0003}.wide{width:100%;margin-top:10px}.icon{width:20px;height:20px;flex-shrink:0;vertical-align:middle;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}#app{position:relative;max-width:1480px;min-height:100vh;margin:auto;display:grid;grid-template-columns:minmax(0,1fr) 390px;gap:28px;padding:24px}.arena{min-width:0;display:flex;flex-direction:column;justify-content:center}.board-head{display:flex;justify-content:space-between;align-items:center;gap:10px;margin:0 8px}.board-head>div{padding:12px 18px;border-radius:17px;background:#24170dbb;border:1px solid var(--line)}.board-head strong{font-size:20px}.board-head p{margin:6px 0 0;color:var(--muted);font-size:13px}.dot{display:inline-block;width:16px;height:16px;border-radius:50%;margin-right:10px;vertical-align:middle;box-shadow:0 0 15px currentColor}.yellow{--gem:#ffc600;background:#ffc600}.blue{--gem:#1482ff;background:#1482ff}.red{--gem:#f34244;background:#f34244}#boardWrap{width:100%;max-width:890px;margin:0 auto;overflow:hidden}#board{display:block;width:100%;max-height:73vh;min-height:400px;filter:drop-shadow(0 13px 7px #0006);touch-action:manipulation;overflow:visible}#board .cell{cursor:pointer}#board .cell:focus{outline:none;stroke:#39b98d;stroke-width:3}#board .bead{cursor:pointer}.board-actions{display:flex;justify-content:center;gap:14px;margin-top:18px}.board-actions button{min-width:130px}#legend{display:flex;gap:24px;justify-content:center;font-size:13px;color:var(--muted);padding:12px;background:#21150d88;border:1px solid var(--line);border-radius:13px;align-self:center}#legend span{display:flex;align-items:center;gap:8px}.key{display:inline-block;width:16px;height:16px;border-radius:50%}.key.selected{border:2px solid #ffd657;box-shadow:0 0 5px #ffd657}.key.legal{border:3px solid #7cddba}.key.path{width:23px;height:0;border-top:2px dashed #ffce42;border-radius:0}.panel{background:linear-gradient(140deg,#3e2919ed,#201309ed);border:1px solid #d1a76963;border-radius:24px;padding:24px;box-shadow:0 15px 40px #0005;align-self:center}.brand{display:flex;align-items:center;gap:12px;padding:0 0 22px;border-bottom:1px solid var(--line)}.brand img{object-fit:contain;border-radius:9px}.brand h1{font-family:'Trebuchet MS','Arial Rounded MT Bold',sans-serif;font-size:35px;letter-spacing:-1px;white-space:nowrap;color:#ffe5a7;text-shadow:0 2px 1px #6a4316,0 0 20px #f7c35e44;margin:0}h2{display:flex;gap:10px;align-items:center;font-size:19px;margin:20px 0 14px}h2 small{margin-left:auto;font-size:11px;font-weight:400;color:var(--muted)}.seg{display:flex;gap:8px;margin-bottom:10px}.seg>button{flex:1;padding:10px 8px;font-size:13px}.disabled-modes button{font-size:11px}label:not(.switch):not(.language){display:block;font-size:13px;color:var(--muted);margin:17px 0 8px}select{width:100%;appearance:auto;display:block;background-color:#392615}.switch{display:flex;justify-content:space-between;align-items:center;margin-top:15px;gap:12px;font-size:13px}.switch span{display:flex;gap:8px;align-items:center}input[type=checkbox]{accent-color:#e8bf64;width:34px;height:20px;cursor:pointer}.gem{display:inline-block;border-radius:50%;width:22px;height:22px;background:radial-gradient(circle at 30% 25%,#ffffffef 1%,#ffffff60 12%,transparent 28%),radial-gradient(circle at 60% 65%,var(--gem),#080906 130%);box-shadow:inset 1px 1px 2px #fff,0 2px 4px #0006;border:1px solid #ffe5a788}.global-settings{border-top:1px solid var(--line);border-bottom:1px solid var(--line);display:flex;gap:10px;padding:15px 0;margin-top:18px;align-items:center}.global-settings button{font-size:13px;padding:9px}.language{display:flex;gap:5px;align-items:center;margin-left:auto}.language select{font-size:12px;padding:8px;width:105px}.extras{display:flex;gap:8px;margin-top:15px}.extras button{flex:1;font-size:12px;padding:9px 5px}footer{font-size:10px;text-align:center;color:#bd9d75;line-height:1.8;margin-top:16px}.player{display:flex;gap:10px;align-items:center;justify-content:space-between;padding:15px;border:1px solid var(--line);border-radius:12px;margin:10px 0}.player.current{border-color:#e7bf64;background:#d4ac4217}.player span:first-child{display:flex;align-items:center;gap:10px}.player small{font-size:12px;color:var(--muted)}dl{margin:18px 0 8px}dl>div{display:flex;justify-content:space-between;padding:10px 0;border-bottom:1px solid var(--line)}dt{display:flex;align-items:center;gap:10px;font-size:14px}dd{margin:0;font-variant-numeric:tabular-nums}#recordScope{display:block;text-align:center;color:var(--muted);font-size:11px;min-height:18px}dialog{border:1px solid #b78d52;border-radius:22px;background:linear-gradient(135deg,#443020,#20160f);color:var(--cream);width:min(560px,94vw);max-height:90vh;padding:28px;box-shadow:0 20px 100px #0009}dialog::backdrop{background:#0e0906b8;backdrop-filter:blur(5px)}dialog h2{font-size:24px}dialog p,dialog li{line-height:1.9;color:#e3cba8}dialog ul{padding-left:20px}.result{font-size:38px;text-align:center;color:#ffe29a;padding:12px}.result-sub{text-align:center}.record-row{display:flex;justify-content:space-between;border-bottom:1px solid var(--line);padding:12px 0;font-size:13px}.badge{display:inline-flex;padding:8px 15px;background:#d7a84325;border:1px solid #dab653;border-radius:30px;color:#ffe29a}.modal-actions{display:flex;gap:10px;margin:15px 0}.modal-actions button{flex:1}#toast{position:fixed;bottom:24px;left:50%;transform:translateX(-50%) translateY(150%);background:#fff1d2;color:#33200e;box-shadow:0 3px 20px #0007;padding:12px 22px;border-radius:30px;z-index:50;transition:transform .2s;max-width:90vw;text-align:center;font-size:14px}#toast.show{transform:translateX(-50%)}#tourCard{margin:12px auto 0;background:#2e2116f0;border:1px solid #d6af62;border-radius:16px;padding:16px;max-width:690px;width:100%}#tourCard p{font-size:14px;line-height:1.65;margin:6px 0 12px;color:#f0dcb9}.tour-controls{display:flex;gap:6px;flex-wrap:wrap}.tour-controls button{font-size:12px;padding:8px 10px}.tour-controls select{width:85px;font-size:12px;padding:8px}.tour-title{display:flex;justify-content:space-between;gap:10px;font-size:15px}.paused-overlay{pointer-events:none}button.busy{opacity:.6}[hidden]{display:none!important}.record-table{max-height:260px;overflow:auto}.help-note{font-size:12px;color:#cfb791}.settings-grid{display:grid;gap:12px}
@media(min-width:1500px){#app{padding-top:35px;padding-bottom:35px}}@media(max-width:1000px){#app{grid-template-columns:minmax(0,1fr) 320px;gap:12px;padding:14px}.panel{padding:18px}.brand h1{font-size:28px}.brand img{width:43px;height:48px}.board-head strong{font-size:16px}.board-head button{font-size:0;padding:10px}.board-head p{font-size:11px}.board-actions button{min-width:0;flex:1}.seg>button{font-size:12px}#board{min-height:320px}}
@media(max-width:720px){#app{display:flex;flex-direction:column;padding:12px;gap:18px}.panel{width:100%;max-width:550px;margin:auto;align-self:stretch;padding:20px}.brand{justify-content:center}.brand h1{font-size:36px}#board{max-height:none;min-height:0}.arena{width:100%}.board-head{margin:0}.board-head>div{padding:10px 12px}.board-head p{font-size:12px}.board-actions{margin-top:12px;gap:8px}.board-actions button{padding:10px;font-size:13px}#legend{gap:15px;font-size:11px;padding:9px}.panel h2{margin-top:16px}.seg>button{font-size:14px}.brand img{width:50px;height:55px}.global-settings{justify-content:center}.language{margin-left:10px}.tour-controls button{flex:1;white-space:nowrap}#tourCard{padding:12px}.result{font-size:30px}}
@media(prefers-reduced-motion:reduce){*,*:before,*:after{transition:none!important;animation:none!important;scroll-behavior:auto!important}}

#toast{visibility:hidden;opacity:0}#toast.show{visibility:visible;opacity:1}

#quickControls{border-bottom:1px solid var(--line);padding-bottom:8px}#quickControls>label{display:flex;align-items:center;gap:8px;margin-top:14px}#quickControls .help-note{font-size:10px;margin:8px 0}#quickControls .seg{margin-bottom:5px}

.purple{--gem:#a45be8;background:#a45be8}.lime{--gem:#a5d936;background:#a5d936}[data-color]{min-width:44px!important;padding:8px!important}[data-color] .gem{width:28px;height:28px}[data-color].active{box-shadow:inset 0 0 0 1px #f9d16d,0 0 9px #ffd56b33}

.roster{display:grid;gap:8px;margin-top:12px}.roster-row{padding:10px;border:1px solid var(--line);border-radius:12px;background:#180f0933}.roster-heading{display:flex;justify-content:space-between;align-items:center;gap:8px}.roster-heading strong{display:flex;align-items:center;gap:8px;font-size:13px}.roster-heading select{width:100px;min-height:36px;padding:5px 10px;font-size:13px}.palette{display:flex;gap:7px;margin-top:8px}.palette button{flex:1;min-width:36px!important;min-height:38px;padding:5px!important}.palette .gem{width:22px;height:22px}#quickControls .roster-row{padding:8px}#quickControls .roster{gap:6px}#quickControls .roster-heading strong{font-size:12px}#quickControls .palette{margin-top:5px}.difficulty button{display:flex;gap:7px}.difficulty-icon{width:21px;height:21px}#app{align-items:start}.panel{align-self:start}#playing .seg button{font-size:12px}.arena{position:sticky;top:18px}@media(max-width:720px){.arena{position:static}.palette button{min-height:44px}.roster-heading select{min-height:44px}}

#sessionActions{display:flex;justify-content:flex-end;gap:9px;padding:12px 8px 0}#sessionActions button{font-size:13px;background:#2e1f13e8}#sessionActions button:first-child{border-color:#d6ad67}@media(max-width:720px){#sessionActions{justify-content:center;padding:10px 0 2px}#sessionActions button{flex:1;font-size:12px;padding:9px}}
/* Fill the desktop viewport; keep the board visible while controls scroll. */
@media(min-width:721px){
 html,body{height:100%;overflow:hidden}
 #app{width:100%;max-width:none;height:100dvh;min-height:0;padding:14px;gap:18px;grid-template-columns:minmax(0,1fr) clamp(300px,25vw,380px)}
 .arena{position:relative;top:auto;height:100%;min-height:0;justify-content:flex-start;gap:8px}
 .board-head{flex-shrink:0;margin:0}.board-head>div{padding:10px 16px}
 #sessionActions{flex-shrink:0;padding:0;position:absolute;right:0;top:72px;z-index:2}
 #sessionActions button{min-height:36px;padding:7px 10px;font-size:12px}
 #boardWrap{flex:1;min-height:0;max-width:none;display:flex;align-items:center;justify-content:center;overflow:hidden}
 #board{height:100%;width:100%;min-height:0;max-height:none}
 #legend{flex-shrink:0;padding:7px 14px;font-size:11px}
 .board-actions{flex-shrink:0;margin:0;gap:10px}.board-actions button{min-height:38px;padding:7px 14px}
 .panel{height:100%;max-height:100%;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:#9d7444 #26180d;padding:18px}
 .brand{padding-bottom:12px}.brand h1{font-size:30px}
 #tourCard{flex-shrink:0;margin:0 auto;padding:10px;max-height:24vh;overflow:auto}
}
@media(max-width:720px){
 #app{padding:8px;gap:12px}.arena{gap:7px}
 #boardWrap{max-width:none}#board{height:auto;width:100%;max-height:76dvh;min-height:0}
 .panel{max-width:none}.board-head strong{font-size:15px}
}
/* Let the star use the full arena height, with controls in the side corners. */
@media(min-width:721px){
 #boardWrap{position:absolute;inset:0}
 .board-head{position:relative;z-index:2;pointer-events:none}.board-head>*{pointer-events:auto}
 #legend{position:absolute;left:0;bottom:50px;z-index:2;max-width:210px;flex-wrap:wrap;gap:8px}
 .board-actions{position:absolute;left:0;bottom:0;z-index:2;gap:6px}
 .board-actions button{min-width:0;padding:7px 10px;font-size:12px}
 #tourCard{position:absolute;bottom:94px;left:0;max-width:280px;z-index:3}
}
/* Larger move legend at the opposite corner from the settings button. */
#legend{font-size:14.3px;padding:9.1px 18.2px;border-radius:16.9px;gap:10.4px}
#legend span{gap:10.4px}
#legend .key{width:20.8px;height:20.8px;flex-shrink:0}
#legend .key.selected{border-width:2.6px}
#legend .key.legal{border-width:3.9px}
#legend .key.path{width:29.9px;height:0;border-top-width:2.6px;border-radius:0}
@media(min-width:721px){#legend{left:auto;right:0;bottom:0;max-width:273px}}
@media(max-width:720px){#legend{align-self:flex-end;flex-wrap:wrap;max-width:100%}}
/* Mobile and touch-tablet menu drawer. Desktop keeps its sidebar. */
#menuToggle,#menuClose,#menuBackdrop{display:none}
body.compact{height:100dvh;overflow:hidden}
body.compact #app{display:block;width:100%;height:100dvh;min-height:0;padding:8px;max-width:none}
body.compact .arena{position:relative;top:auto;display:flex;width:100%;height:100%;min-height:0;gap:6px;justify-content:flex-start}
body.compact .board-head{position:relative;flex-shrink:0;margin:0;padding-right:46px;gap:6px}
body.compact .board-head>div{padding:8px 10px;min-width:0}
body.compact .board-head strong{font-size:14px}
body.compact .board-head p{font-size:11px;margin-top:4px}
body.compact .board-head>button{font-size:0;padding:8px;flex-shrink:0}
body.compact #boardWrap{position:relative;inset:auto;flex:1;min-height:0;width:100%;max-width:none;display:flex;align-items:center;justify-content:center}
body.compact #board{width:100%;height:100%;min-height:0;max-height:none}
body.compact #sessionActions{position:static;padding:0;gap:6px;flex-shrink:0}
body.compact #sessionActions button{padding:6px 8px;min-height:36px;font-size:11px}
body.compact #legend{position:static;left:auto;right:auto;bottom:auto;flex-shrink:0;align-self:flex-end;max-width:100%;gap:8px;font-size:12px;padding:7px 10px}
body.compact #legend span{gap:6px}
body.compact .board-actions{position:static;left:auto;bottom:auto;flex-shrink:0;margin:0;gap:6px}
body.compact .board-actions button{min-width:0;min-height:40px;flex:1;padding:7px 8px;font-size:12px}
body.compact #tourCard{position:static;max-height:25dvh;overflow:auto;max-width:none;margin:0;flex-shrink:0;padding:10px}
body.compact #menuToggle{display:flex;position:fixed;right:max(8px,env(safe-area-inset-right));top:max(8px,env(safe-area-inset-top));width:44px;height:44px;padding:0;font-size:25px;z-index:11;background:#352213f2}
body.compact #menuBackdrop{display:block;position:fixed;inset:0;min-height:0;border:0;border-radius:0;background:#0e09068a;z-index:20;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .26s,visibility .26s}
body.compact #gameMenu{position:fixed;inset:0 0 0 auto;z-index:21;width:min(380px,92vw);max-width:none;height:100dvh;max-height:100dvh;margin:0;border-radius:22px 0 0 22px;padding:18px;padding-top:max(18px,env(safe-area-inset-top));padding-bottom:max(18px,env(safe-area-inset-bottom));overflow-y:auto;overscroll-behavior:contain;transform:translateX(105%);visibility:hidden;transition:transform .28s ease,visibility .28s;box-shadow:-12px 0 45px #0007}
body.compact #gameMenu .brand{justify-content:flex-start;padding-right:38px;padding-bottom:14px}
body.compact #gameMenu .brand h1{font-size:28px}
body.compact #gameMenu .brand img{width:42px;height:46px}
body.compact #menuClose{display:flex;position:absolute;right:12px;top:max(16px,env(safe-area-inset-top));width:36px;min-height:36px;padding:0;font-size:27px;z-index:1}
body.compact.menu-open #gameMenu{transform:translateX(0);visibility:visible}
body.compact.menu-open #menuBackdrop{opacity:1;visibility:visible;pointer-events:auto}
@media(max-height:500px){body.compact .board-head p{display:none}body.compact #legend{position:absolute;right:0;bottom:46px;max-width:140px;font-size:10px;pointer-events:none}body.compact #sessionActions{position:absolute;top:50px;right:0;max-width:170px;flex-wrap:wrap}body.compact #boardWrap{position:absolute;inset:0}body.compact .board-actions{margin-top:auto;max-width:260px;z-index:2}body.compact .board-head{z-index:2}}
/* Section titles share the same emphasis in Korean and English. */
#setup label.menu-section-label,#quickControls label.menu-section-label{font-size:16.9px;font-weight:700}
@font-face{font-family:CrystalTitle;src:url('assets/fonts/cinzel-decorative-700.ttf') format('truetype');font-weight:700;font-style:normal;font-display:swap}
.brand h1{font-family:CrystalTitle,Georgia,serif;font-weight:700;font-size:29px;letter-spacing:.4px;line-height:1.25;color:#ffe7ad;text-shadow:0 2px 2px #3b210c,0 0 20px #f5bd5a45}
@supports(background-clip:text){.brand h1{background:linear-gradient(180deg,#fff9e6 12%,#ffe5a1 47%,#dca953 82%,#f9db92);background-clip:text;-webkit-background-clip:text;color:transparent;text-shadow:0 2px 12px #f5bd5a24}}
@media(min-width:721px) and (max-width:1000px){.brand h1{font-size:25px}}
@media(max-width:720px){.brand h1{font-size:28px}}
body.compact #gameMenu .brand h1{font-size:25px;letter-spacing:0}

.board-actions{flex-wrap:wrap}.board-actions button{min-width:0}.tour-controls label[for="replaySpeed"]{margin:0;align-self:center}.tour-controls #replaySpeed{width:100px}
#victoryFloor,#victoryCrystals{pointer-events:none}
body.celebrating #menuToggle{visibility:hidden}
body.celebrating .board-actions,body.celebrating #playing button{visibility:hidden}
body.celebrating #turnText{color:#fff1c3;text-shadow:0 0 14px #f9d16d80}

.global-settings{flex-wrap:wrap}#fullscreenBtn{flex:0 0 100%;width:100%}
