/* Isolated learning surfaces; existing card palette/art and match layout stay intact. */
.learning-dialog{--learn-ink:#183d31;--learn-gold:#a78b46;box-sizing:border-box;width:min(1020px,calc(100vw - 20px));max-width:none;max-height:calc(100dvh - 20px);padding:0;border:1px solid #b5a36b;border-radius:18px;background:#f7f3e7;color:var(--learn-ink);overflow:auto;overscroll-behavior:contain;box-shadow:0 24px 90px #001c1890;font-family:system-ui,-apple-system,sans-serif;}
.learning-dialog::backdrop{background:#071c19c9;backdrop-filter:blur(3px)}
.learning-dialog button,.learning-entry button{min-height:44px;touch-action:manipulation;cursor:pointer;white-space:normal}
.learning-dialog button:focus-visible{outline:3px solid #b58928;outline-offset:3px}
.learn-header{display:flex;justify-content:space-between;align-items:center;gap:12px;margin:0;padding:16px 22px;background:#133d31;color:#f6edcf;border-bottom:2px solid #b19852;position:sticky;top:0;z-index:3;border-radius:0;}
.learn-header small{font-size:10px;letter-spacing:.17em;color:#d8c890}.learn-header h2{font-size:clamp(18px,3vw,26px);margin:4px 0;line-height:1.25}.learn-header button{flex-shrink:0;border:1px solid #c8b573;background:#254d3e;color:#fff4d2;padding:8px 13px;border-radius:10px;}
.learn-body{padding:24px;line-height:1.85}.learning-dialog p{line-height:1.85}.learning-dialog h3{line-height:1.4;margin:10px 0 16px;font-size:clamp(21px,3.5vw,30px);font-weight:650;letter-spacing:.02em}.learn-kicker{color:#766535;font-size:12px;font-weight:700;letter-spacing:.08em}.learn-small{font-size:12px;color:#596c60}.learn-book-tools{display:flex;gap:8px;align-items:end;padding:14px 22px;background:#ebe9d9;border-bottom:1px solid #d9d7c3;}.learn-book-tools label{flex:1;min-width:0;font-size:12px}.learn-book-tools input{box-sizing:border-box;width:100%;min-height:44px;background:#fffef7;color:#183d31;border:1px solid #b4bfac;border-radius:8px;padding:10px;font-size:16px}.learn-book-tools button,.learn-chapter-nav button,.learn-practice-tools button,.learn-zone-bar button,.learning-dialog [data-learn-rules],#learning-card-rules{border:1px solid #b5bea8;background:#fbfaef;color:#244638;border-radius:8px;padding:8px 12px;}.learn-book-cover{text-align:center;padding:18px 16px 32px;border-bottom:1px solid #ccc7ac;margin-bottom:20px;background:radial-gradient(ellipse at center,#fffef5 0%,#efeedd 100%);}.learn-book-cover h3{font-family:serif;font-size:clamp(26px,5vw,42px);line-height:1.6}.learn-book-cover small{display:block;color:#736339;letter-spacing:.08em;font-size:12px}.learn-emblem{display:block;font-size:58px;line-height:1.2;color:#a88c45}.learn-book-cover button{border:0;border-bottom:1px solid #6f7655;background:transparent;color:#234a38;padding:8px 12px;font-weight:700}.learn-contents{display:grid;grid-template-columns:1fr 1fr;gap:10px}.learn-contents>button{display:flex;align-items:center;text-align:left;gap:13px;border:1px solid #d3d4bf;border-radius:10px;background:#fffdf4;color:#183d31;padding:15px;}.learn-contents>button>span{font:24px Georgia,serif;color:#a18d52}.learn-contents strong{font-size:15px;display:block}.learn-contents small{font-size:12px;line-height:1.6;display:block;color:#627263;margin-top:5px}.learn-contents b{margin-left:auto;color:#a18d52}.learn-chapter{max-width:780px;margin:auto}.learn-lead{font-size:19px;background:#e5eadb;border-left:4px solid #b19852;padding:16px 20px}.learn-term{display:inline!important;min-height:0!important;border:0!important;border-bottom:1px dotted #8a7b40!important;border-radius:0!important;background:none!important;color:inherit!important;font:inherit!important;padding:0 1px!important;line-height:inherit!important}.learn-glossary .learn-term{display:inline-block!important;min-height:44px!important;margin:6px 12px 6px 0;}.learn-rulings,.learn-sources,.learn-glossary,.learn-log{border-top:1px solid #cccfb8;margin-top:22px;padding-top:14px}.learning-dialog summary{cursor:pointer;min-height:38px;font-weight:700}.learn-rulings p{padding-bottom:16px;border-bottom:1px solid #e0e1d1}.learn-source-paragraph{white-space:pre-wrap;overflow-wrap:anywhere;font-size:13px}.learn-sources details{padding:12px;border:1px solid #d5d8c9;margin:10px 0;background:#fffdf7}.learn-sources h4{font-size:15px;margin-top:22px}.learn-chapter-nav{display:flex;justify-content:space-between;gap:8px;margin:30px 0 4px}.learn-examples{display:flex;gap:12px;overflow-x:auto;padding:12px 4px;}.learn-examples>button{width:120px;min-width:120px;display:block;padding:5px;border:0;background:transparent;color:#254538}.learn-examples>button>span{display:block;font-size:12px;margin-top:6px}.learn-examples .card{width:100%;height:auto;aspect-ratio:63/88;}.learn-diagram{margin:20px 0;padding:18px;background:#e5e9dc;border:1px solid #bdc7af;border-radius:12px}.learn-diagram figcaption{margin-bottom:12px;font-weight:700}.learn-diagram>.learn-board{max-width:360px;margin:auto}.learn-flow{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:10px;padding:0;list-style-position:inside}.learn-flow li{background:#fbfaee;border:1px solid #c3c5ac;border-radius:8px;padding:12px;font-size:14px}.learn-board{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}.learn-board-cell{min-width:0;background:#dfe6d4;border:1px solid #adbda1;border-radius:7px;display:flex;flex-direction:column;overflow:hidden;}.learn-board-cell>span{font-size:10px;text-align:center;line-height:1.5;padding:3px;color:#42604a}.learn-board-cell>button{border:0;background:transparent;padding:3px;width:100%;min-height:0;}.learn-board-cell .card,.learn-board-cell .egg-card{width:100%;aspect-ratio:63/88;height:auto;margin:0;}.learn-board-cell i{display:flex;align-items:center;justify-content:center;min-height:58px;flex:1;font-size:26px;color:#92a68b;font-style:normal}.learn-diagram .learn-board-cell{min-height:75px}.learn-diagram .egg-card{max-height:100px;width:auto;margin:auto}.learn-practice-tools{display:flex;gap:6px;flex-wrap:wrap;padding:10px 20px;border-bottom:1px solid #cccdb8;}.learn-practice-tools button{font-size:12px;min-height:38px}.learn-welcome{padding:8px 0 20px}.learn-lesson-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin-bottom:24px}.learn-lesson-grid button{padding:18px;text-align:left;border:1px solid #c8cdb6;border-radius:12px;background:#fffdf4;color:#234b37}.learn-lesson-grid span,.learn-lesson-grid small{display:block;font-size:11px;color:#82723d}.learn-lesson-grid strong{display:block;margin:7px 0;font-size:16px}.learn-primary{border:1px solid #a18b40!important;border-radius:9px!important;background:#1c4b38!important;color:#fff5d1!important;padding:12px 18px!important;min-height:46px;font-size:15px;font-weight:700}.learn-instruction{padding:18px;background:#fffef5;border:1px solid #c5c6ac;border-left:4px solid #b39c55;border-radius:9px;margin:14px 0;}.learn-instruction h3{font-size:22px;margin:0 0 9px}.learn-instruction p{margin:8px 0}.learn-instruction [data-learn-rules]{margin:8px 0 0 8px;font-size:12px}.learn-match-meta{padding:7px 10px;background:#153e32;color:#e7dfbd;border-radius:8px;font-size:13px}.learn-table{display:grid;grid-template-columns:1fr 1fr;gap:18px;margin:12px 0}.learn-side{min-width:0;max-width:400px}.learn-side h4{margin:8px 0;display:flex;justify-content:space-between;gap:8px;font-size:14px}.learn-side h4 span{font-size:12px;font-weight:400}.learn-opponent{min-width:0}.learn-opponent>summary{font-size:12px}.learn-zone-bar{display:flex;flex-wrap:wrap;gap:6px;font-size:11px;align-items:center;margin-top:7px}.learn-zone-bar button{font-size:11px;padding:5px;min-height:32px}.learn-hand{border-top:1px solid #bcc7ae;padding-top:10px}.learn-hand h4{margin:5px 0;font-size:15px}.learn-hand h4 span{font-size:11px;font-weight:400}.learn-hand>div{display:flex;gap:12px;overflow:auto;padding:9px 5px 16px;}.learn-hand button{border:1px solid #b5bca5;min-width:108px;width:108px;border-radius:8px;padding:5px;background:#f6f6e9;color:#2a4938}.learn-hand .card{width:100%;height:auto;aspect-ratio:63/88}.learn-hand button>span,.learn-hand button>strong{display:block;font-size:11px;margin-top:4px}.learn-hand .learn-next-card{outline:3px solid #b39735;outline-offset:2px;background:#fff1b7;box-shadow:0 0 0 6px #d5c26a30}.learn-chain{padding:10px 16px;border:1px solid #c2aa65;background:#f1e9cf;border-radius:8px;margin-top:12px}.learn-chain h4{margin:2px}.learn-log{font-size:12px}.learn-log ol{padding-left:22px}.learn-card-detail{display:grid;grid-template-columns:minmax(170px,290px) 1fr;gap:24px;padding:24px;line-height:1.85}.learn-full-card .card,.learn-full-card .egg-card{width:100%;height:auto;aspect-ratio:63/88;}.learn-full-card{min-width:0}.learn-card-detail h3{font-size:22px}#learning-card-dialog{width:min(760px,calc(100vw - 20px))}#learning-term-dialog{width:min(480px,calc(100vw - 32px));padding:0 0 20px}#learning-term-close{margin:0 24px;min-width:100px}#rulebook-results{padding:0 24px;font-size:12px}.learn-hint{padding:12px;background:#e6ecd9;border-radius:6px}#tutorial-storage{padding:0 24px 12px}#tutorial-play progress{width:100%;height:5px;accent-color:#8f7a33}#tutorial-hint{font-size:12px;line-height:1.6}.learn-card-back{padding:3px}.learn-card-back small{display:block;font-size:10px;text-align:center}.learning-entry{margin:16px 0;padding:16px;border:1px solid #b9a96d;border-radius:12px;background:linear-gradient(135deg,#173e32,#284f3e);color:#f4edce}.learning-entry h3{margin:0 0 7px}.learning-entry p{font-size:13px}.learning-entry button{margin:4px;padding:10px 14px;border:1px solid #c3b06a;background:#f1ead1;color:#20432e;border-radius:8px}.learning-links{display:flex;gap:8px;flex-wrap:wrap;margin:12px 0}.learning-links button{min-height:44px}.learning-related{min-height:44px;margin-top:10px}.learning-open{overflow:hidden}
@media(max-width:620px){.learning-dialog{width:calc(100vw - 10px);max-height:calc(100dvh - 10px);border-radius:12px}.learn-header{padding:12px 14px}.learn-header h2{font-size:20px}.learn-header button{font-size:12px;padding:6px 10px}.learn-body{padding:16px}.learn-book-tools{padding:10px 14px;gap:6px;flex-wrap:wrap}.learn-book-tools label{flex-basis:100%}.learn-book-tools button{flex:1}.learn-contents{grid-template-columns:1fr}.learn-contents>button{padding:13px}.learn-lesson-grid{grid-template-columns:1fr 1fr;gap:8px}.learn-lesson-grid button{padding:13px}.learn-lesson-grid strong{font-size:14px}.learn-practice-tools{padding:8px 12px;gap:5px}.learn-practice-tools button{font-size:11px;padding:6px 8px}.learn-table{display:flex;flex-direction:column;gap:5px}.learn-side{max-width:320px;margin:auto;width:100%}.learn-board-cell .card,.learn-board-cell .egg-card{max-height:116px}.learn-side h4{font-size:12px}.learn-instruction{padding:12px}.learn-instruction h3{font-size:19px}.learn-lead{font-size:17px;padding:12px}.learn-instruction [data-learn-rules]{margin-left:0}.learn-card-detail{display:flex;flex-direction:column;padding:16px;gap:10px}.learn-full-card{width:min(230px,70vw);margin:auto}.learn-card-detail>div:last-child{width:100%}.learn-card-detail h3{font-size:20px}.learn-diagram{padding:12px}.learn-flow{grid-template-columns:1fr 1fr}.learn-flow li{font-size:12px}.learn-chapter-nav button{font-size:12px;padding:8px}.learn-hand button{min-width:104px;width:104px}.learn-opponent>summary{font-size:11px} }
@media(max-height:500px){.learning-dialog{max-height:calc(100dvh - 6px)}.learn-header{position:static;padding:8px 14px}.learn-header small{display:none}.learn-card-detail{display:grid;grid-template-columns:170px 1fr}.learn-full-card{width:170px}.learn-body{padding:14px 22px}.learn-book-cover{padding:8px}.learn-practice-tools{padding:6px 16px}}
@media(prefers-reduced-motion:reduce){.learning-dialog *{animation:none!important;transition:none!important;scroll-behavior:auto!important}}

/* Current rulings share a chapter with the short explanation. */
.learn-view-switch{display:flex;gap:6px;margin:14px 0;flex-wrap:wrap}
.learn-view-switch button{flex:1;font-size:13px;background:#eeeddd;color:#254638;border-color:#adb99c;padding:8px}
.learn-view-switch [aria-pressed=true]{background:#254c3b;color:#fff3cc;border-color:#8d783c}
.learn-book-tools .learn-search-scope{flex:0 1 130px}.learn-search-scope select{display:block;width:100%;background:#fffef7;color:#183d31;font-size:13px}
.learn-sources>section,.learn-search-hits article{padding:14px 0;border-top:1px solid #d4d7c3;overflow-wrap:anywhere}
.learn-sources h4{font-size:18px;line-height:1.5;margin:4px 0 14px}.learn-sources p,.learn-sources li,.learn-search-hits p{font-size:15px;line-height:1.9;margin:12px 0}
.learn-sources ul{padding-left:22px}.learn-rule-table{table-layout:fixed;border-collapse:collapse;width:100%;font-size:13px;margin:16px 0}
.learn-rule-table td,.learn-rule-table th{border:1px solid #bac6af;padding:8px;overflow-wrap:anywhere;text-align:left}.learn-rule-table th{background:#e3e8d8}
.learn-search-hits>h3{font-size:19px}.learn-search-hits article>button{background:#254c3b;text-align:left;width:100%}
.learn-examples{flex-wrap:wrap;overflow:visible}.learn-examples>button{width:110px;min-width:0;flex:0 1 110px}
/* Same match renderer, controls, field arrangement and card detail as ordinary play. */
#tutorial-dialog{position:fixed;inset:auto;margin:0;left:calc(var(--ui-vleft,0px) + env(safe-area-inset-left) + 4px);top:calc(var(--ui-vtop,0px) + env(safe-area-inset-top) + 4px);width:calc(var(--ui-vw,100vw) - env(safe-area-inset-left) - env(safe-area-inset-right) - 8px);height:calc(var(--ui-vh,100dvh) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 8px);max-height:none;overflow:hidden}
#tutorial-dialog[open]{display:flex;flex-direction:column}#tutorial-dialog>.learn-header{padding:3px 10px;min-height:50px;flex:none;position:static;gap:6px}
#tutorial-dialog .learn-header h2{font-size:17px;margin:0}#tutorial-dialog .learn-header small{font-size:8px}
#tutorial-tools{flex:none;border-bottom:1px solid #c7cbb8;padding:0 10px;font-size:11px;max-height:35%;overflow:auto}
#tutorial-tools>summary{display:list-item;min-height:32px;line-height:32px}#tutorial-tools .learn-practice-tools{padding:4px 0 8px}
#tutorial-lesson-list{overflow:auto;min-height:0;flex:1}#tutorial-play{padding:5px;min-height:0;flex:1;display:flex;flex-direction:column;gap:4px;overflow:hidden}
.learn-coach{flex:none;max-height:175px;overflow-y:auto;overscroll-behavior:contain;padding:0 4px}
#tutorial-progress{font-size:10px;line-height:16px}#tutorial-play progress{display:block;height:3px;margin:2px 0}
#tutorial-dialog .learn-instruction{display:flex;align-items:start;gap:6px;padding:6px 8px;margin:4px 0;border-radius:6px}
#tutorial-dialog .learn-instruction>div{flex:1;min-width:0}#tutorial-dialog .learn-instruction h3{font-size:15px;line-height:1.3;margin:0 0 3px}
#tutorial-dialog .learn-instruction p{font-size:12px;line-height:1.55;margin:0}
#tutorial-dialog .learn-instruction [data-learn-rules]{flex:none;margin:0;padding:3px 5px;width:48px;font-size:10px;line-height:1.3}
.learn-last-result,.learn-cpu-status,#tutorial-hint{font-size:10px!important;line-height:1.4!important;margin:3px 0;color:#254c3b}
#tutorial-storage{font-size:9px;line-height:13px;padding:0 8px 3px;flex:none;margin:0}
#tutorial-finish .learn-primary,.learn-coach>[data-learn-continue]{padding:6px 12px!important;font-size:12px;min-height:44px}
.tutorial-match{min-height:0;min-width:0;display:flex;flex:1;flex-direction:column;gap:4px;background:#132d2c;color:#f6f0dc;padding:3px;border-radius:8px}
.tutorial-match .table-top{gap:5px}.tutorial-match .table-top button{white-space:normal}
.tutorial-match .slot .card-tap{min-height:0}.tutorial-match .management>[data-learn-zone]{border:1px solid #78906e;border-radius:5px;background:#142e28;display:flex;flex-direction:column;align-items:center;justify-content:center;min-width:0;min-height:0;padding:2px;font-size:8px;overflow:hidden;gap:2px}
#tutorial-operation-panel{min-height:0;min-width:0;padding:3px;border:1px solid #9c9865;border-radius:10px;background:#193d32;overflow:auto;align-self:start;max-height:100%}
#tutorial-match .learn-next-card,#tutorial-match .learn-next-command{outline:3px solid #ffdf7d;outline-offset:1px;box-shadow:0 0 0 4px #d6b44650}
#tutorial-match .learn-next-command{background:#f0d99d;color:#193d32}
#tutorial-result{flex:none;text-align:center;padding:6px;font-size:12px}#tutorial-result h2{font-size:15px}
#learning-card-dialog{width:calc(var(--ui-vw,100vw) - env(safe-area-inset-left) - env(safe-area-inset-right) - 16px);max-height:none;padding:8px;background:#18392f;color:#f9f1d9;border-radius:14px}
#learning-card-dialog h3{font-size:14px;margin:0 0 5px;line-height:1.4}#learning-card-dialog p{line-height:1.6}#learning-card-dialog .learn-small{color:#bdd0c1}
#learning-card-dialog [data-learn-command]{border:2px solid #ffdf7d}
@media(max-width:620px){.learn-book-tools>label:first-child{flex:1 1 100%}.learn-book-tools .learn-search-scope{flex:1 1 110px}.learn-book-tools>button{flex:1 1 60px}}
/* Practice is one scroll surface. Board rows never compete with coach/hand height. */
#tutorial-play{display:block;overflow-y:auto;overscroll-behavior:contain;scroll-padding:8px;padding-bottom:12px}
.learn-coach{max-height:none;height:auto;overflow:visible;padding:0 4px 6px}
#tutorial-dialog .learn-instruction details{margin-top:4px}
#tutorial-dialog .learn-instruction summary{min-height:32px;line-height:32px;font-size:12px}
#tutorial-dialog .learn-instruction details p{padding:4px 0 8px}
.learn-target-guide{min-height:44px;padding:6px 10px;font-size:12px;border:1px solid #a18b40;background:#234b38;color:#fff5d1}
.tutorial-match{height:auto;min-height:0;flex:none;gap:6px}
.tutorial-match .battle-area,.tutorial-match .battle-area:has(.response-options){flex:none;grid-template-columns:minmax(0,1fr);grid-template-rows:auto auto auto;gap:6px}
.tutorial-match .board-shell{overflow:visible;min-height:0;padding:2px}
.tutorial-match .player-board{width:100%;max-width:none;display:grid;grid-template-rows:auto minmax(0,1fr) auto}
.tutorial-match .player-board.own{height:260px;min-height:260px}
.tutorial-match .player-board.opponent{height:132px;min-height:132px}
.tutorial-match .board-layout{grid-template-rows:minmax(0,1fr);min-height:0}
.tutorial-match .board-field{min-height:0;display:flex;flex-direction:column}
.tutorial-match .slots{flex:1;height:100%;grid-template-rows:repeat(3,minmax(0,1fr))}
.tutorial-match .slot{height:auto;min-height:0;aspect-ratio:auto}
.tutorial-match .own .slot{min-height:54px}
.tutorial-match .slot-content{container-type:size}
.tutorial-match .own .slot-content .card-tap{height:min(100cqh,150cqw);width:min(100cqw,66.6667cqh);aspect-ratio:2/3;display:grid;place-items:center}
.tutorial-match .own .slot .card-face,.tutorial-match .own .slot .card-back{height:100%;width:100%;aspect-ratio:2/3}
.tutorial-match .opponent .management>[data-learn-zone=deck]{grid-row:1}
.tutorial-match .opponent .management>[data-learn-zone=activation]{grid-row:2}
.tutorial-match .opponent .management>[data-learn-zone=discard]{grid-row:3}
#tutorial-operation-panel,#tutorial-operation-panel:has(.response-options){position:static;grid-column:1/-1;align-self:stretch;height:auto;min-height:60px;max-height:none;overflow:visible;padding:4px}
#tutorial-operation-panel .operation-notice{height:auto;min-height:50px}
#tutorial-operation-panel .notice-actions{max-height:none;overflow:visible}
#tutorial-operation-panel .notice-expand{height:auto}
.tutorial-match .hand-panel:not(.hand-collapsed){display:block}
.tutorial-match .hand-panel .hand-heading{height:44px;flex-direction:row}
.tutorial-match .hand-heading button{min-height:44px;height:auto;padding:5px 8px;font-size:12px;width:auto}
.tutorial-match .hand-panel .cards{height:86px;padding:5px 5px 9px}
.tutorial-match .hand-entry{width:48px;flex-basis:48px}.tutorial-match .hand-card{width:48px;height:72px}
#tutorial-tools{position:static;max-width:none;max-height:35%;flex-shrink:0}
@media(orientation:portrait){
 .tutorial-match .opponent .player-heading{min-height:18px;height:18px}
 .tutorial-match .opponent .board-metrics{min-height:14px}
 .tutorial-match .opponent .management>[data-learn-zone]{flex-direction:row;font-size:7px;gap:2px}
}
@media(orientation:landscape){
 .tutorial-match .slot-content .card-tap{height:min(100cqh,150cqw);width:min(100cqw,66.6667cqh);aspect-ratio:2/3;display:grid;place-items:center}
 .tutorial-match .slot .card-face,.tutorial-match .slot .card-back{height:100%;width:100%;aspect-ratio:2/3}
 #tutorial-play{display:grid;grid-template-columns:minmax(170px,.32fr) minmax(0,1fr);align-items:start;gap:8px}
 .tutorial-match .battle-area,.tutorial-match .battle-area:has(.response-options){grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:auto auto}
 .tutorial-match .player-board.opponent,.tutorial-match .player-board.own{height:280px;min-height:280px}
 #tutorial-dialog>.learn-header{min-height:44px}#tutorial-dialog .learn-header small{display:none}
 #tutorial-dialog .learn-instruction{display:block}#tutorial-dialog .learn-instruction [data-learn-rules]{width:auto;margin-top:6px}
}
