:root{
  --ink:#172019;
  --muted:#687269;
  --line:#dce2db;
  --paper:#fbfcf8;
  --panel:#f4f6f1;
  --green:#275b42;
  --green-dark:#173c2b;
  --green-soft:#e8f1ea;
  --amber:#e59b24;
  --amber-soft:#fff4dd;
  --danger:#a83a32;
  --shadow:0 12px 36px rgba(24,39,29,.12);
  --board-size:min(70vh,64vw,760px);
}
*{box-sizing:border-box}
html,body{width:100%;height:100%;margin:0;overflow:hidden}
body{font-family:Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;color:var(--ink);background:#e9ede8}
button,select{font:inherit}
button{cursor:pointer}
button:focus-visible,select:focus-visible,summary:focus-visible{outline:3px solid rgba(39,91,66,.3);outline-offset:2px}
button:disabled{cursor:not-allowed;opacity:.45}
[hidden]{display:none!important}

.chess-app{display:grid;grid-template-rows:minmax(82px,11.5vh) minmax(0,1fr);width:100vw;height:100dvh;min-height:480px;background:linear-gradient(135deg,#f5f7f3 0%,#e6ebe5 100%)}
.tutorial-bar{position:relative;z-index:10;display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:14px;padding:10px clamp(12px,2vw,28px);border-bottom:1px solid #cad4cb;background:rgba(250,252,248,.96);box-shadow:0 5px 24px rgba(26,48,34,.08)}
.brand-mark{display:grid;place-items:center;width:48px;height:48px;border-radius:15px;color:#fff;background:linear-gradient(145deg,var(--green),var(--green-dark));font-size:30px;box-shadow:0 8px 20px rgba(23,60,43,.22)}
.tutorial-copy{min-width:0}
.tutorial-heading-row{display:flex;align-items:center;gap:10px;margin-bottom:4px}
.tutorial-heading-row h1{margin:0;font-family:Georgia,serif;font-size:clamp(17px,1.5vw,23px);line-height:1;color:#1e3428}
.engine-pill{display:inline-flex;align-items:center;gap:6px;padding:4px 8px;border:1px solid #c9d8cd;border-radius:999px;color:#41624e;background:#eef5ef;font-size:10px;font-weight:800;letter-spacing:.04em;text-transform:uppercase;white-space:nowrap}
.engine-dot{width:7px;height:7px;border-radius:50%;background:#38a865;box-shadow:0 0 0 4px rgba(56,168,101,.13)}
.tutorial-message{display:flex;gap:8px;min-width:0;font-size:clamp(11px,1.05vw,14px);line-height:1.35}
.tutorial-message strong{flex:0 0 auto;color:var(--green-dark)}
.tutorial-message span{min-width:0;color:#48554c;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.turn-chip{display:flex;align-items:center;gap:12px;padding:7px 12px;border:1px solid #d8ded8;border-radius:13px;background:#fff;box-shadow:0 4px 14px rgba(24,39,29,.07)}
.turn-chip span{display:flex;flex-direction:column;gap:1px;min-width:48px}
.turn-chip small{color:#7a847d;font-size:9px;font-weight:800;text-transform:uppercase;letter-spacing:.08em}
.turn-chip b{font-size:12px;color:#20362a}
.turn-chip i{width:1px;height:25px;background:#dde3dd}
.tutorial-bar[data-kind="grave"],.tutorial-bar[data-kind="errore"]{border-bottom-color:#d7a39e;background:#fff8f6}
.tutorial-bar[data-kind="imprecisione"]{border-bottom-color:#dfc67d;background:#fffdf4}
.tutorial-bar[data-kind="suggestion"]{border-bottom-color:#a9c7b2;background:#f7fbf7}
.tutorial-flash{animation:tutorialFlash .45s ease}
@keyframes tutorialFlash{50%{box-shadow:inset 0 -4px 0 rgba(39,91,66,.18),0 5px 24px rgba(26,48,34,.08)}}

.game-workspace{position:relative;display:grid;grid-template-columns:minmax(210px,16vw) 32px minmax(330px,1fr) minmax(210px,16vw);min-width:0;min-height:0;overflow:hidden;transition:grid-template-columns .25s ease}
.game-workspace.left-collapsed{grid-template-columns:44px 32px minmax(330px,1fr) minmax(210px,16vw)}
.game-workspace.right-collapsed{grid-template-columns:minmax(210px,16vw) 32px minmax(330px,1fr) 44px}
.game-workspace.left-collapsed.right-collapsed{grid-template-columns:44px 32px minmax(330px,1fr) 44px}

.side-panel{position:relative;z-index:4;min-width:0;min-height:0;border-color:var(--line);background:rgba(248,250,246,.94);box-shadow:var(--shadow)}
.left-panel{border-right:1px solid var(--line)}
.right-panel{border-left:1px solid var(--line)}
.panel-body{height:100%;padding:clamp(12px,1.3vw,20px);overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:#c8d2ca transparent}
.panel-heading{display:flex;align-items:center;justify-content:space-between;margin-bottom:clamp(12px,2vh,22px)}
.panel-heading h2{margin:2px 0 0;font-family:Georgia,serif;font-size:clamp(18px,1.5vw,24px);font-weight:700}
.eyebrow{color:#6c786f;font-size:9px;font-weight:900;letter-spacing:.12em;text-transform:uppercase}
.panel-icon{display:grid;place-items:center;width:34px;height:34px;border-radius:10px;color:var(--green);background:var(--green-soft);font-size:18px}
.panel-toggle{position:absolute;z-index:8;top:14px;display:grid;place-items:center;width:28px;height:38px;padding:0;border:1px solid #cfd8d1;color:var(--green-dark);background:#fff;box-shadow:0 5px 14px rgba(30,52,38,.12)}
.panel-toggle span{font-size:22px;line-height:1}
.panel-toggle b{display:none}
.panel-toggle-left{right:-14px;border-radius:0 10px 10px 0}
.panel-toggle-right{left:-14px;border-radius:10px 0 0 10px}
.game-workspace.left-collapsed .left-panel .panel-body,.game-workspace.right-collapsed .right-panel .panel-body{display:none}
.game-workspace.left-collapsed .panel-toggle-left,.game-workspace.right-collapsed .panel-toggle-right{position:static;display:flex;flex-direction:column;gap:12px;width:100%;height:100%;border:0;border-radius:0;background:linear-gradient(#f6f8f4,#edf2ed);box-shadow:none;writing-mode:vertical-rl}
.game-workspace.left-collapsed .panel-toggle-left span,.game-workspace.right-collapsed .panel-toggle-right span{transform:rotate(180deg)}
.game-workspace.left-collapsed .panel-toggle-left b,.game-workspace.right-collapsed .panel-toggle-right b{display:block;font-size:10px;letter-spacing:.12em;text-transform:uppercase}

.control-group{display:grid;gap:8px;margin:0 0 clamp(12px,1.8vh,20px);padding-bottom:clamp(12px,1.8vh,20px);border-bottom:1px solid var(--line)}
.compact-group{gap:6px;margin-bottom:12px;padding-bottom:12px}
.control-label{display:flex;flex-direction:column;gap:2px}
.control-label span{font-size:13px;font-weight:850}
.control-label small{color:var(--muted);font-size:10px;line-height:1.3}
.segmented{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:4px;padding:3px;border:1px solid #d7ded7;border-radius:10px;background:#e9eee9}
.segmented button{display:flex;align-items:center;justify-content:center;gap:6px;min-height:34px;padding:6px 8px;border:0;border-radius:8px;color:#58635b;background:transparent;font-size:11px;font-weight:850;transition:.16s ease}
.segmented button:hover{background:rgba(255,255,255,.7)}
.segmented button.active{color:#fff;background:var(--green);box-shadow:0 3px 10px rgba(39,91,66,.2)}
.segmented button.selected-no.active,.segmented button[data-auto-play="off"].active,.segmented button[data-auto-suggest="off"].active{background:#8b514a}
.segmented.mini button{font-size:9px;min-height:28px}
.color-dot{width:12px;height:12px;border-radius:50%;border:1px solid #adb4ae}
.white-dot{background:#fff}.black-dot{background:#1a211c;border-color:#1a211c}
select{width:100%;min-height:38px;padding:7px 34px 7px 10px;border:1px solid #cfd8d1;border-radius:9px;color:#24352a;background:#fff;font-size:12px;font-weight:750}
.lesson-card{display:flex;gap:10px;padding:12px;border:1px solid #dfc687;border-radius:12px;background:linear-gradient(145deg,#fffaf0,var(--amber-soft))}
.lesson-icon{display:grid;place-items:center;flex:0 0 29px;height:29px;border-radius:9px;color:#fff;background:#b97813;font-weight:900}
.lesson-card b{font-size:11px}.lesson-card p{margin:4px 0 0;color:#6a5a3e;font-size:10px;line-height:1.42}
.save-state{display:flex;align-items:center;gap:7px;margin-top:12px;color:#68736a;font-size:9px;line-height:1.3}
.save-state-dot{flex:0 0 7px;width:7px;height:7px;border-radius:50%;background:#e1a333}
.server-status.ok+.save-state-dot{background:#42a66b}

.evaluation-rail{display:grid;grid-template-rows:22px minmax(0,1fr) 22px;align-items:center;justify-items:center;gap:4px;padding:12px 4px;background:#19211c}
.rail-player{display:grid;place-items:center;width:20px;height:20px;border-radius:50%;font-size:8px;font-weight:950}
.rail-black{color:#fff;background:#070907;border:1px solid #4e5c52}.rail-white{color:#1b211d;background:#fff;border:1px solid #ccd3cd}
.evaluation-bar{position:relative;width:17px;height:100%;min-height:150px;overflow:hidden;border:1px solid #647067;border-radius:999px;background:#101511;box-shadow:inset 0 0 0 1px rgba(255,255,255,.08)}
.eval-white{position:absolute;right:0;bottom:0;left:0;height:50%;background:#f6f6ed;transition:height .45s ease}
.eval-center{position:absolute;right:0;left:0;top:50%;height:2px;background:var(--amber);box-shadow:0 0 6px rgba(229,155,36,.8)}

.center-stage{display:grid;grid-template-rows:auto minmax(0,1fr) auto;gap:7px;min-width:0;min-height:0;padding:8px clamp(8px,1.2vw,18px);overflow:hidden}
.suggestion-strip{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:11px;min-height:70px;padding:8px 10px;border:1px solid #d9e0da;border-radius:14px;background:rgba(255,255,255,.92);box-shadow:0 6px 18px rgba(30,50,37,.08)}
.suggestion-piece{display:grid;place-items:center;width:48px;height:48px;border-radius:12px;color:#fff;background:linear-gradient(145deg,var(--green),var(--green-dark));font-family:Georgia,serif;font-size:31px}
.suggestion-main{min-width:0}
.suggestion-title-row{display:flex;align-items:baseline;gap:9px;min-width:0;margin:1px 0 2px}
.suggestion-title-row strong{overflow:hidden;color:#1c3125;font-family:Georgia,serif;font-size:clamp(14px,1.2vw,19px);text-overflow:ellipsis;white-space:nowrap}
.suggestion-title-row span{flex:0 0 auto;padding:3px 7px;border-radius:7px;color:#7c4d0a;background:#fff1d2;font-size:10px;font-weight:900;letter-spacing:.04em}
.suggestion-text{max-width:72ch;margin:0;overflow:hidden;color:#667168;font-size:10px;line-height:1.35;text-overflow:ellipsis;white-space:nowrap}
.suggestion-actions{display:flex;gap:6px}
.button{min-height:36px;padding:7px 11px;border:1px solid transparent;border-radius:9px;font-size:11px;font-weight:850;transition:transform .15s ease,box-shadow .15s ease,background .15s ease}
.button:hover:not(:disabled){transform:translateY(-1px)}
.button.primary{color:#fff;background:var(--green);box-shadow:0 5px 14px rgba(39,91,66,.18)}
.button.secondary{border-color:#cad5cc;color:var(--green-dark);background:#fff}
.button.quiet{width:100%;border-color:#d8ded8;color:#415148;background:#f7f9f6}
.button small{display:block;font-size:7px;font-weight:650}

.board-stage{display:grid;place-items:center;min-width:0;min-height:0;overflow:hidden}
.board-shell{display:grid;grid-template-rows:16px minmax(0,1fr) 16px;width:var(--board-size);height:var(--board-size);max-width:100%;max-height:100%;filter:drop-shadow(0 14px 20px rgba(24,35,27,.18))}
.board-row{display:grid;grid-template-columns:16px minmax(0,1fr) 16px;min-width:0;min-height:0}
.board{display:grid;grid-template-columns:repeat(8,1fr);grid-template-rows:repeat(8,1fr);min-width:0;min-height:0;overflow:hidden;border:2px solid #18251d;border-radius:5px;background:#bd7521}
.square{position:relative;display:grid;place-items:center;min-width:0;min-height:0;overflow:hidden}
.light{background:#f1dbad}.dark{background:#c98121}
.piece{position:relative;z-index:2;width:92%;height:92%;object-fit:contain;user-select:none;-webkit-user-drag:none;touch-action:none}
.piece.my-piece{cursor:grab}.piece.my-piece:active{cursor:grabbing}.piece.opponent-piece{cursor:not-allowed}
.files{display:grid;grid-template-columns:16px repeat(8,1fr) 16px;align-items:center;color:#6d786f;font-size:8px;font-weight:850;text-transform:uppercase}
.files span{text-align:center}.files span:first-child{grid-column:2}
.ranks{display:grid;grid-template-rows:repeat(8,1fr);align-items:center;color:#6d786f;font-size:8px;font-weight:850}
.ranks span{text-align:center}
.square.selected{box-shadow:inset 0 0 0 5px #fff45b}
.square.last{box-shadow:inset 0 0 0 4px rgba(255,255,255,.42)}
.square.legal::after{content:"";position:absolute;z-index:4;width:25%;height:25%;border-radius:50%;background:rgba(35,111,65,.66)}
.square.capture::after{content:"";position:absolute;inset:8%;z-index:4;border:5px solid rgba(174,45,37,.7);border-radius:50%}
.square.hover-target{box-shadow:inset 0 0 0 6px #4fd576}
.square.suggest-from,.square.suggest-to{z-index:3;box-shadow:inset 0 0 0 6px #ffb52d,0 0 0 2px rgba(255,181,45,.38);animation:suggestPulse .75s ease-in-out infinite alternate}
@keyframes suggestPulse{to{box-shadow:inset 0 0 0 9px #fff1a0,0 0 16px 3px rgba(255,181,45,.75)}}
.auto-move-origin{box-shadow:inset 0 0 0 6px #f5c84c}.auto-move-destination{box-shadow:inset 0 0 0 6px #47c66c}
.auto-source-hidden{opacity:.1}.auto-move-ghost{position:fixed;z-index:9999;pointer-events:none;transition:transform var(--auto-move-ms) cubic-bezier(.2,.8,.2,1)}.auto-move-ghost.fly{transform:translate(var(--auto-dx),var(--auto-dy))}
.piece-captured-destroy{animation:captureDestroy .42s ease forwards}@keyframes captureDestroy{to{opacity:0;transform:scale(.2) rotate(35deg);filter:hue-rotate(130deg) saturate(2)}}
.drag-ghost{position:fixed;z-index:99999;width:80px;height:80px;pointer-events:none;object-fit:contain}

.board-evaluation{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:10px;min-height:52px;padding:7px 10px;border:1px solid #dfd5ba;border-radius:12px;background:linear-gradient(135deg,#fffdfa,#fff7e8)}
.evaluation-badge{padding:5px 7px;border-radius:7px;color:#fff;background:#a96f13;font-size:8px;font-weight:950;letter-spacing:.08em;text-transform:uppercase}
.evaluation-copy{display:flex;flex-direction:column;min-width:0}
.evaluation-copy strong{overflow:hidden;font-size:12px;text-overflow:ellipsis;white-space:nowrap}.evaluation-copy small{overflow:hidden;color:#766b59;font-size:8px;text-overflow:ellipsis;white-space:nowrap}
.analysis-move{max-width:210px;overflow:hidden;color:#496052;font-size:9px;font-weight:800;text-overflow:ellipsis;white-space:nowrap}

.primary-actions{display:grid;grid-template-columns:1fr;gap:7px;margin-bottom:12px}
.right-panel .primary-actions .button{width:100%;min-height:38px}
.pause-button{width:100%;margin-bottom:10px;color:#fff;background:#a76b12}
.message-card{padding:9px;border:1px solid #d8e1da;border-radius:10px;color:#4e5c52;background:#fff;font-size:9px;line-height:1.35}
.move-warning{display:grid;gap:3px;margin-top:8px;padding:9px;border:1px solid #e1aa70;border-radius:10px;color:#713219;background:#fff0e1;font-size:9px;line-height:1.35}.move-warning.grave{color:#6e1919;background:#ffe7e5;border-color:#dba19d}.move-warning.imprecisione{color:#73570e;background:#fff8d8}
.micro-status{min-height:11px;color:#778078;font-size:8px;line-height:1.25}
.tools-drawer{margin-top:10px;border:1px solid #d5ddd6;border-radius:10px;background:#fff}
.tools-drawer summary{padding:9px;color:#3a4e40;font-size:10px;font-weight:850;cursor:pointer}
.tools-content{display:grid;gap:7px;max-height:34vh;overflow:auto;padding:0 9px 9px}
.tools-content h3{margin:4px 0 0;font-size:10px}
.perfect-sequence-timer{padding:6px;border-radius:7px;color:#31543e;background:#e9f4ec;font-size:9px;text-align:center}
.history-settings{display:grid;gap:5px;padding:7px;border-radius:8px;background:#f5f7f3;font-size:9px;font-weight:800}
.number-buttons{display:grid;grid-template-columns:repeat(5,1fr);gap:3px}.number-buttons button{min-height:25px;border:1px solid #d1d9d2;border-radius:6px;background:#fff;font-size:9px}.number-buttons button.active{color:#fff;background:var(--green)}
.move-history{max-height:90px;overflow:auto;border:1px solid #e0e5e0;border-radius:7px;background:#fbfcfa}
.move-history-row{display:grid;grid-template-columns:24px 38px 1fr;gap:4px;width:100%;padding:5px;border:0;border-top:1px solid #e5e9e5;color:#344138;background:transparent;font-size:8px;text-align:left}.move-history-row:first-child{border-top:0}.move-history-row:hover{background:#eef5ef}.move-history-number,.move-history-color{font-weight:850}.move-history-empty{padding:7px;color:#7b847d;font-size:8px;text-align:center}.move-history-move small{display:block;margin-top:2px;color:#8a5a45}
.utility-actions{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-top:10px}.utility-actions button{min-height:29px;border:1px solid #d3dbd4;border-radius:7px;color:#566158;background:#fff;font-size:9px;font-weight:800}

@media(max-height:700px){
  .chess-app{grid-template-rows:76px minmax(0,1fr)}
  .tutorial-bar{padding-top:7px;padding-bottom:7px}.brand-mark{width:42px;height:42px;font-size:26px}
  .panel-body{padding:10px}.panel-heading{margin-bottom:10px}.control-group{margin-bottom:10px;padding-bottom:10px}.lesson-card{padding:9px}
  .suggestion-strip{min-height:62px}.suggestion-piece{width:42px;height:42px;font-size:27px}
  .board-evaluation{min-height:46px}.tools-content{max-height:28vh}
}
@media(max-width:1100px){
  .game-workspace{grid-template-columns:minmax(190px,18vw) 27px minmax(310px,1fr) minmax(190px,18vw)}
  .game-workspace.left-collapsed{grid-template-columns:40px 27px minmax(310px,1fr) minmax(190px,18vw)}
  .game-workspace.right-collapsed{grid-template-columns:minmax(190px,18vw) 27px minmax(310px,1fr) 40px}
  .game-workspace.left-collapsed.right-collapsed{grid-template-columns:40px 27px minmax(310px,1fr) 40px}
  .panel-body{padding:10px}.lesson-card{display:none}.analysis-move{display:none}
}
@media(max-width:820px){
  .tutorial-bar{grid-template-columns:auto minmax(0,1fr);gap:9px}.turn-chip{display:none}.tutorial-message strong{display:none}
  .game-workspace,.game-workspace.left-collapsed,.game-workspace.right-collapsed,.game-workspace.left-collapsed.right-collapsed{grid-template-columns:40px 24px minmax(250px,1fr) 40px}
  .side-panel{position:absolute;top:0;bottom:0;width:min(260px,82vw);transition:width .2s ease}
  .left-panel{left:0}.right-panel{right:0}
  .game-workspace.left-collapsed .left-panel,.game-workspace.right-collapsed .right-panel{width:40px}
  .evaluation-rail{grid-column:2}.center-stage{grid-column:3}.right-panel{grid-column:4}
  .suggestion-actions .button{padding:6px 8px}.suggestion-actions .button small{display:none}
}
@media(max-width:560px){
  .chess-app{grid-template-rows:68px minmax(0,1fr);min-height:420px}.tutorial-bar{padding:7px 9px}.brand-mark{width:38px;height:38px;border-radius:11px;font-size:23px}.engine-pill{display:none}.tutorial-message{font-size:10px}
  .center-stage{gap:5px;padding:5px}.suggestion-strip{grid-template-columns:minmax(0,1fr) auto;min-height:56px;padding:6px 7px}.suggestion-piece{display:none}.suggestion-title-row strong{font-size:12px}.suggestion-text{font-size:8px}.suggestion-actions{gap:3px}.suggestion-actions .button{min-height:31px;padding:5px 7px;font-size:9px}.button span{display:none}
  .board-evaluation{min-height:42px;padding:5px 7px}.evaluation-badge{display:none}.evaluation-copy strong{font-size:10px}
  .files{font-size:7px}.ranks{font-size:7px}
}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}}
