@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Libre+Baskerville:wght@400;700&display=swap');

:root {
  color-scheme: light;
  --paper: #faf6ed;
  --ink: #293650;
  --muted: #647086;
  --green: #436b59;
  --line: #dce2dc;
  --light: #fff1d5;
  --dark: #87b29b;
  --purple: #7863ad;
  --yellow: #f5cc67;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(circle at 90% 6%, #ece6fa 0, transparent 30%), radial-gradient(circle at 0 40%, #e4f0e8 0, transparent 26%), var(--paper);
  color: var(--ink);
  font: 15px/1.6 'DM Sans', system-ui, sans-serif;
}
button, select { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button {
  cursor: pointer;
  color: var(--ink);
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 3px 0 #2936500b;
  transition: background .15s, transform .15s, box-shadow .15s;
}
button:hover:not(:disabled) { background: #edf3e9; transform: translateY(-2px); box-shadow: 0 5px 0 #2936500c; }
button:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, a:focus-visible, select:focus-visible { outline: 3px solid #a46219; outline-offset: 3px; }
a { color: inherit; }
header { max-width: 1240px; margin: auto; display: flex; align-items: center; justify-content: space-between; padding: 18px 32px; border-bottom: 1px solid var(--line); }
.back { font-size: 13px; text-decoration: none; padding: 5px 0; }
.brand { font-family: 'Libre Baskerville', Georgia, serif; font-size: 20px; text-decoration: none; display: flex; gap: 10px; align-items: center; }
.brand span { font-size: 30px; background: var(--yellow); width: 44px; height: 44px; text-align: center; border-radius: 14px; transform: rotate(-7deg); }
.header-note { font-size: 12px; color: var(--muted); }
main { max-width: 1150px; margin: auto; padding: 40px 28px; }
.intro { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 30px; }
.eyebrow { font-size: 10px; font-weight: 700; letter-spacing: 1.7px; color: var(--green); margin: 0 0 12px; }
h1, h2 { font-family: 'Libre Baskerville', Georgia, serif; }
h1 { font-size: 46px; line-height: 1.25; font-weight: 700; letter-spacing: -1.8px; margin: 0 0 16px; }
h1 span { color: var(--purple); }
.intro p:not(.eyebrow) { color: var(--muted); font-size: 14px; max-width: 440px; margin: 0; }
.intro-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.intro-badges span { background: #e8f0e3; color: #42644b; border: 1px solid #d7e3d1; border-radius: 30px; padding: 5px 10px; font-size: 10px; font-weight: 600; }
.intro-badges span:nth-child(2) { background: #eee8f7; border-color: #e2d8ef; color: #68548a; }
.intro-badges span:nth-child(3) { background: #fff0cf; border-color: #efdfb6; color: #7c6128; }
.daily-stamp { position: relative; border: 2px dashed #c59d43; border-radius: 36px; width: 186px; min-width: 186px; height: 168px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; transform: rotate(5deg); background: #fff0c9; box-shadow: 7px 7px 0 #dfd2a044; }
.daily-stamp span { letter-spacing: 3px; font-size: 11px; }
.daily-stamp .stamp-spark { font-size: 30px; letter-spacing: 0; color: #ad782a; line-height: 1; }
.daily-stamp strong { font-size: 18px; }
.daily-stamp small { font-size: 10px; color: #776035; }
.tabs { display: flex; gap: 8px; margin-bottom: 24px; padding: 6px; width: fit-content; max-width: 100%; border: 1px solid var(--line); border-radius: 17px; background: #e9ede6; }
.tabs button { border: 0; padding: 10px 20px; font-weight: 700; box-shadow: none; background: transparent; }
.tabs button[aria-pressed=true] { background: var(--ink); color: white; box-shadow: 0 3px 0 #141d33; }
.tabs span { margin-left: 8px; font-size: 11px; border-radius: 20px; background: #ffffff26; padding: 2px 6px; }
.game-layout { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(280px,1fr); gap: 26px; align-items: start; }
.board-panel { min-width: 0; padding: 18px; background: #fffdf8; border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 8px 0 #dce4d680, 0 18px 35px #29365008; }
.board { width: 100%; aspect-ratio: 1; display: grid; grid-template-columns: repeat(8,1fr); border: 8px solid #436b59; border-radius: 12px; box-shadow: 0 5px 0 #2c4e40; overflow: hidden; }
.square { padding: 0; border: 0; border-radius: 0; background: var(--light); position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 1; touch-action: manipulation; min-width: 0; box-shadow: none; }
.square.dark { background: var(--dark); }
.square:hover:not(:disabled) { background: #f5d484; transform: none; box-shadow: none; }
.square.dark:hover:not(:disabled) { background: #a4c5a1; }
.square:active:not(:disabled) { transform: none; }
.square.selected, .square.selected:hover { background: #f1c65f; }
.square.last { box-shadow: inset 0 0 0 100px #f4d16744; }
.square.target:after { content: ''; width: 23%; height: 23%; border-radius: 50%; background: #254b4166; position: absolute; pointer-events: none; }
.square.target.occupied:after { width: 85%; height: 85%; background: transparent; border: 4px solid #284b3980; }
.square.hint { box-shadow: inset 0 0 0 4px #9864b7; }
.square.check { background: #e59889; }
.piece { display: block; width: 88%; height: 88%; z-index: 1; pointer-events: none; flex-shrink: 0; filter: drop-shadow(0 2px 1px #24342822); }
.square.selected .piece { transform: translateY(-3px); }
.coordinate { position: absolute; font-size: 9px; font-weight: 700; line-height: 1; color: #314e3e; pointer-events: none; z-index: 2; }
.rank { top: 4px; left: 4px; }
.file { bottom: 3px; right: 4px; }
.player-row { display: flex; align-items: center; gap: 10px; padding: 0 0 14px; min-height: 58px; }
.player-row strong { font-size: 13px; display: block; }
.player-row small { font-size: 11px; color: var(--muted); display: block; }
.avatar { background: #e6e7f4; border: 1px solid #d9d9eb; border-radius: 13px; width: 42px; height: 42px; display: grid; place-items: center; flex-shrink: 0; }
.avatar.light { background: #fff0cd; border-color: #eadbb6; }
.avatar .piece { width: 35px; height: 35px; }
.pill { margin-left: auto; font-size: 9px; font-weight: 700; letter-spacing: 1px; border-radius: 20px; padding: 5px 9px; background: #e5eee4; color: var(--green); white-space: nowrap; }
.bottom { padding-top: 20px; padding-bottom: 6px; }
.turn-dot { width: 10px; height: 10px; background: #5a9b6e; border: 2px solid #daebd8; box-shadow: 0 0 0 4px #edf5e9; border-radius: 50%; margin-left: auto; flex-shrink: 0; }
.board-actions { display: flex; gap: 7px; margin-top: 14px; flex-wrap: wrap; }
.board-actions button { font-size: 11px; flex: 1; white-space: nowrap; padding: 9px 8px; }
#hint { background: #f1ebfa; border-color: #ddd0f0; color: #634b8d; }
#new-game { background: #e5eee1; border-color: #ccdfc6; color: #426343; }
.settings { display: flex; flex-wrap: wrap; gap: 10px 20px; padding-top: 17px; font-size: 11px; color: var(--muted); }
select { border: 1px solid #e0e4da; border-radius: 7px; background: #fafbf6; color: var(--ink); padding: 4px; max-width: 125px; }
aside { display: grid; gap: 17px; }
.panel { background: #fffdf8; border: 1px solid var(--line); padding: 24px; border-radius: 22px; box-shadow: 0 5px 0 #e3e5da80; }
.coach { background: linear-gradient(150deg,#f5efff,#fffdf8 65%); border-color: #dfd6ef; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-heading .eyebrow { margin: 0; }
.coach .eyebrow { color: #73569c; }
.coach-icon { font-size: 26px; color: #73569c; width: 43px; height: 43px; text-align: center; background: #e9dff8; border: 1px solid #dbcced; border-radius: 15px; transform: rotate(8deg); }
h2 { font-size: 20px; font-weight: 400; margin: 12px 0 16px; line-height: 1.4; }
.rating { display: inline-block; border-radius: 25px; padding: 6px 12px; font-size: 11px; font-weight: 700; }
.rating:before { content: '●'; padding-right: 7px; font-size: 9px; }
.neutral { background: #e9e8f0; color: #615a77; }
.excellent, .good { background: #dfeddd; color: #365d38; }
.rating.excellent:before { content: '★'; }
.inaccuracy { background: #faebc2; color: #7d5d18; }
.mistake, .blunder { background: #f7dfd8; color: #923c2b; }
#feedback { font-size: 14px; margin: 16px 0; line-height: 1.8; }
.alternative { font-size: 13px; border-left: 3px solid var(--purple); padding: 10px 12px; background: #f1ebf7; border-radius: 0 10px 10px 0; }
.coach-note { font-size: 11px; color: var(--muted); border-top: 1px solid #e2dbea; padding-top: 15px; margin-top: 22px; line-height: 1.7; }
.muted { color: var(--muted); font-size: 9px; letter-spacing: 1px; }
.history-panel h2 { font-size: 15px; margin: 0; }
.history-panel { padding-bottom: 15px; }
#history { list-style: none; padding: 0; margin: 15px 0 0; max-height: 208px; overflow: auto; font-size: 12px; font-variant-numeric: tabular-nums; }
#history li { padding: 7px 8px; border-top: 1px solid #ecece1; display: flex; gap: 10px; align-items: center; border-radius: 7px; }
#history li:nth-child(even) { background: #f2f4ed; }
#history .empty { color: var(--muted); font-style: italic; }
#history .move-number { color: var(--muted); width: 24px; }
#history .move-label { font-weight: 700; min-width: 45px; }
#history .move-rating { margin-left: auto; font-size: 10px; }
#daily-panel { background: #fff5d9; border-color: #e9d7a9; }
.progress { display: flex; gap: 9px; margin: 18px 0; }
.progress button { border-radius: 12px; padding: 0; width: 40px; height: 40px; font-size: 13px; font-weight: 700; background: #fffdf5; border-color: #ddcfab; }
.progress .current { border: 2px solid var(--purple); box-shadow: 0 3px 0 #b8a2cd; }
.progress .solved { background: var(--green); color: white; border-color: #365744; }
.progress .assisted { background: #8a6333; color: white; border-color: #72532e; }
#daily-panel p { font-size: 13px; }
#daily-score { color: #79603b; }
.daily-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.daily-actions button { font-size: 12px; }
.how-to { border-top: 1px solid var(--line); margin-top: 45px; padding-top: 25px; }
.how-to h2 { font-size: 22px; }
.how-to>div { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.how-to>div>p { padding: 18px; margin: 0; background: #eaf0e3; border: 1px solid #dbe4d5; border-radius: 17px; }
.how-to>div>p:nth-child(2) { background: #efe9f7; border-color: #e3d9ef; }
.how-to>div>p:nth-child(3) { background: #fff0d0; border-color: #eddfbc; }
.how-to p { font-size: 12px; color: var(--muted); }
.how-to strong { display: block; color: var(--ink); margin-bottom: 5px; }
details { font-size: 12px; margin-top: 24px; max-width: 800px; }
summary { cursor: pointer; }
footer { max-width: 1150px; margin: auto; padding: 25px 28px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 15px; font-size: 10px; color: var(--muted); }
dialog { border: 1px solid var(--line); border-radius: 22px; background: var(--paper); max-width: 90%; color: var(--ink); padding: 25px; }
dialog::backdrop { background: #29365080; backdrop-filter: blur(3px); }
dialog button { margin: 4px; }
[hidden] { display: none!important; }
@media(max-width:760px) {
  header { padding: 12px 16px; }
  .header-note { display: none; }
  .brand { font-size: 16px; }
  .brand span { width: 34px; height: 34px; font-size: 24px; border-radius: 10px; }
  main { padding: 25px 12px; }
  .intro { gap: 10px; margin-bottom: 22px; align-items: flex-start; }
  h1 { font-size: clamp(25px,6.8vw,35px); letter-spacing: -1px; }
  .intro p:not(.eyebrow) { font-size: 12px; }
  .eyebrow { font-size: 8px; letter-spacing: 1px; }
  .intro-badges { gap: 5px; margin-top: 12px; }
  .intro-badges span { font-size: 9px; padding: 4px 8px; }
  .daily-stamp { width: 108px; height: 133px; min-width: 108px; border-radius: 24px; margin-top: 5px; gap: 6px; box-shadow: 4px 4px 0 #dfd2a044; }
  .daily-stamp strong { font-size: 11px; }
  .daily-stamp span { font-size: 8px; letter-spacing: 1.5px; }
  .daily-stamp .stamp-spark { font-size: 23px; }
  .daily-stamp small { font-size: 8px; max-width: 94px; text-align: center; }
  .game-layout { grid-template-columns: 1fr; gap: 20px; }
  .board-panel { padding: 12px; border-radius: 20px; }
  .board { border-width: 5px; border-radius: 8px; }
  aside { padding-top: 0; gap: 14px; }
  .panel { padding: 20px; }
  .how-to>div { grid-template-columns: 1fr; gap: 10px; }
  .how-to { margin-top: 32px; }
  .tabs button { font-size: 12px; padding: 9px 12px; }
  footer { flex-wrap: wrap; padding: 20px 16px; }
  .coordinate { font-size: 8px; }
  .settings { justify-content: space-between; gap: 10px; }
  .board-actions { gap: 5px; }
  .board-actions button { padding: 8px 6px; font-size: 10px; }
  .player-row small { font-size: 10px; }
  .player-row strong { font-size: 12px; }
  .pill { font-size: 8px; padding: 4px 7px; }
}
@media(prefers-reduced-motion:reduce) {
  *, *:before, *:after { transition: none!important; animation: none!important; }
  .square.selected .piece { transform: none; }
}
