:root {
  color-scheme: light;
  --ink: #201c20;
  --paper: #fffdf2;
  --paper-edge: #d3c9a8;
  --link: #102c77;
  --navy: #101a3b;
  --plum: #57275e;
  --gold: #b28b34;
}

* { box-sizing: border-box; }

html { scroll-behavior: auto; }

body {
  margin: 0;
  color: var(--ink);
  background-color: var(--navy);
  background-image:
    radial-gradient(circle, #f6e7a8 1px, transparent 1.5px),
    radial-gradient(circle, #9da8d3 1px, transparent 1.5px),
    radial-gradient(circle, #ffffff 1px, transparent 1.5px);
  background-size: 71px 71px, 113px 113px, 157px 157px;
  background-position: 7px 12px, 41px 28px, 90px 78px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.55;
}

a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
a:visited { color: #542d72; }
a:hover { color: #8a281f; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 3px solid #ba7622; outline-offset: 3px; }

.site-shell { width: min(900px, calc(100% - 28px)); margin: 26px auto; }
.masthead { text-align: center; padding: 22px 16px 19px; color: #fff9dd; border: 1px solid #58628d; background: #172246; box-shadow: 4px 4px 0 #080e25; }
.masthead-logo { display: block; width: 40px; height: 40px; margin: 0 auto 5px; image-rendering: pixelated; }
.eyebrow { margin: 0 0 4px; color: #e8d68f; font-size: .88rem; letter-spacing: .04em; }
h1 { margin: 0; color: #fff9dd; font-size: clamp(2.7rem, 8vw, 4.4rem); line-height: 1.1; letter-spacing: -.04em; text-shadow: 2px 2px 0 #59386b; }
h1 span { color: #f2d584; }
.tagline { margin: 6px 0 13px; font-size: 1.12rem; }
.welcome-ribbon { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; color: #e4def3; font-size: .92rem; }
.welcome-ribbon b { color: #e6c469; }
.site-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px 19px; margin: 19px -4px -3px; padding: 10px 8px; border-top: 1px dotted #9298b2; border-bottom: 1px dotted #9298b2; }
.site-nav a { color: #fff0b7; }
.site-nav a:visited { color: #e6d2fa; }
.site-nav a:hover { color: #fff; }

main { display: grid; gap: 17px; margin-top: 18px; }
.paper { padding: 19px 23px; border: 1px solid var(--paper-edge); background-color: var(--paper); box-shadow: 3px 3px 0 #080e25; }
h2 { margin: 0 0 8px; color: #42224f; font-size: 1.48rem; line-height: 1.3; }
.paper p { margin: 8px 0; }
.intro { border-top: 5px solid #cba84e; }
.small-note { color: #5c5750; font-size: .9rem; }
.section-intro { margin-top: 0 !important; }
.auth-panel { max-width: 600px; width: 100%; justify-self: center; border-top: 5px solid #705078; }
.auth-tabs { display: flex; gap: 5px; margin: 14px 0 0; border-bottom: 1px solid #b9ae90; }
.tab-button { padding: 5px 13px; border: 1px solid #b9ae90; border-bottom: 0; background: #eee9d7; color: var(--ink); font: inherit; font-size: .94rem; cursor: pointer; }
.tab-button.is-selected { position: relative; top: 1px; background: var(--paper); font-weight: bold; }
.auth-form { display: grid; grid-template-columns: 1fr; gap: 5px; padding: 12px 2px 5px; }
.auth-form label { margin-top: 4px; font-weight: bold; }
.auth-form input { width: 100%; min-height: 38px; padding: 6px 8px; border: 1px solid #857e6a; border-radius: 0; background: #fff; color: var(--ink); font: inherit; }
.auth-form [hidden], [hidden] { display: none !important; }
.bevel-button { min-height: 34px; padding: 4px 11px; border: 1px solid #625e52; border-top-color: #fff; border-left-color: #fff; border-radius: 0; background: #e9e5d8; color: #191919; box-shadow: 1px 1px 0 #746f62; font: inherit; font-size: .94rem; line-height: 1.25; cursor: pointer; }
.bevel-button:active { border-color: #fff #625e52 #625e52 #fff; box-shadow: inset 1px 1px 1px #8c877b; }
.primary-button { justify-self: start; margin-top: 8px; background: #e8ddb5; font-weight: bold; }
.or-rule { display: flex; align-items: center; gap: 10px; margin: 13px 0 8px; color: #645e51; font-size: .88rem; }
.or-rule::before, .or-rule::after { content: ""; flex: 1; border-top: 1px solid #c8c0a9; }
.google-button { width: 100%; background: #f5f2e8; }
.auth-status { min-height: 1.4em; margin: 8px 0 0 !important; color: #42224f; }
.account-summary { padding: 8px 10px; border: 1px dashed #b9ae90; background: #f7f1dc; }
.connection-note { display: flex; align-items: center; gap: 8px; margin: 12px 0 0 !important; color: #625d51; font-size: .86rem; }
.status-dot { width: 9px; height: 9px; border: 1px solid #716b58; border-radius: 50%; background: #d7c989; }
.notes-panel { border-top: 5px solid #567453; }
.guestbook-line { margin-top: 16px !important; text-align: center; color: #5b3860; }
.game-panel { border-top: 5px solid #49734c; }
.site-footer { margin: 18px 0 0; padding: 10px 14px; border: 1px solid #58628d; background: #172246; box-shadow: 3px 3px 0 #080e25; text-align: center; color: #ebe5d1; font-size: .9rem; }
.site-footer p { margin: 4px; }
.site-footer a { color: #fff0b7; }

/* Shared page frame and persistent left navigation. */
.site-shell { width: min(1120px, calc(100% - 28px)); }
.page-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 17px; align-items: start; margin-top: 18px; }
.sidebar { position: sticky; top: 12px; min-width: 0; border: 1px solid #58628d; background: #172246; box-shadow: 3px 3px 0 #080e25; }
.sidebar-menu > summary { padding: 10px 13px; color: #fff0b7; font-weight: bold; cursor: pointer; }
.sidebar-menu > summary:focus-visible { outline: 3px solid #f2d584; outline-offset: -3px; }
.sidebar-menu > summary::marker { color: #e6c469; }
.site-nav { display: grid; justify-content: stretch; gap: 3px; margin: 0; padding: 4px 9px 11px; border: 0; }
.site-nav a { display: block; min-height: 44px; padding: 9px 10px; color: #fff0b7; line-height: 1.45; }
.site-nav a[aria-current="page"] { background: #29345c; font-weight: bold; text-decoration-thickness: 2px; }
.page-content { min-width: 0; }
.page-content main { margin-top: 0; }
.page-content .site-footer { margin-top: 17px; }
.link-button { display: inline-flex; align-items: center; text-decoration: none; }
.compatibility-auth { display: none !important; }

/* Shared hand-made forms for the game UI mounted by app.js. */
#game-root { overflow-wrap: anywhere; }
#game-root button, #game-root select { min-height: 32px; max-width: 100%; padding: 4px 8px; border: 1px solid #625e52; border-top-color: #fff; border-left-color: #fff; border-radius: 0; background: #e9e5d8; color: var(--ink); font: inherit; font-size: .92rem; }
#game-root input { max-width: 100%; font: inherit; }
#game-root a { color: var(--link); }
.game-toolbar, .game-actions, .game-actions > *, .game-toolbar > label { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.game-toolbar { justify-content: space-between; padding: 8px; border: 1px solid #b9ae90; background: #f5f0de; }
.game-toolbar .game-actions { display: contents; }
.game-toolbar .game-actions button, .game-toolbar .import-button, .game-toolbar > button, .game-toolbar select { min-height: 32px; padding: 4px 8px; }
.game-toolbar .import-button { border: 1px solid #625e52; border-top-color: #fff; border-left-color: #fff; background: #e9e5d8; box-shadow: 1px 1px 0 #746f62; cursor: pointer; }
.game-toolbar .speed-label { gap: 5px; white-space: nowrap; }
.game-toolbar select { width: 66px; }
.game-status { min-height: 1.5em; margin: 9px 0 !important; color: #42224f; }
.is-error { color: #8a241e !important; font-weight: bold; }
.hero-heading { margin: 8px 0 12px; padding: 9px 11px; border: 1px dashed #b9ae90; background: #fff9e8; }
.hero-heading h3 { margin: 0; color: #42224f; font-size: 1.25rem; }
.hero-heading p { margin: 3px 0 0; }
.game-layout, .game-lower { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(220px, 1fr); gap: 12px; align-items: start; }
.game-main, .game-side { display: grid; gap: 12px; min-width: 0; }
.game-lower { margin-top: 12px; }
.game-box { min-width: 0; padding: 12px 13px; border: 1px solid #c9bea0; background: #fffef8; }
.game-box h3 { margin: 0 0 7px; color: #42224f; font-size: 1.08rem; }
.game-box h4 { margin: 8px 0 3px; color: #493254; }
.game-box p { margin: 5px 0; }
.current-action { border-top: 3px solid #cba84e; }
.current-action progress { display: block; width: 100%; height: 16px; margin: 8px 0; accent-color: #59744c; }
.resource-line { padding-top: 7px; border-top: 1px dotted #c3b995; font-weight: bold; }
.enemy-line { color: #73302a; }
.muted { color: #625d51; font-size: .9rem; }
.compact-list, .check-list, .item-list { margin: 5px 0 0; padding-left: 20px; }
.compact-list { columns: 2; }
.skill-list, .check-list { columns: 1; }
.complete { color: #35603c; }
.item-list { list-style-type: square; }
.item-list li { display: grid; gap: 1px; margin: 0 0 8px; }
.game-log { max-height: 220px; overflow: auto; padding-left: 21px; }
.game-log li { padding: 2px 0; border-bottom: 1px dotted #d3c9a8; }
.bag-content { max-height: 250px; overflow-y: auto; overscroll-behavior: contain; }
.log-filters { display: flex; flex-wrap: wrap; gap: 2px 11px; margin: 5px 0 9px; }
.log-filter { font-size: .9rem; white-space: nowrap; }
.action-resources { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 12px; margin-top: 5px; }
.action-resources p, .enemy-summary p { margin: 2px 0; }
.enemy-summary { margin-top: 9px; padding-top: 7px; border-top: 1px dotted #b9ae90; }
.enemy-summary h4 { margin: 0 0 4px; }
.rarity-common { color: #201c20; }
.rarity-uncommon { color: #1554a0; }
.rarity-rare { color: #28733b; }
.rarity-common, .rarity-uncommon, .rarity-rare { font-weight: 600; }
.slot-picker > p:first-child { font-weight: bold; }
.slot-buttons, .game-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.slot-button { min-width: 105px; }
.creation-box, .save-conflict { margin-top: 10px; padding: 13px; border: 1px dashed #aa9d79; background: #fff9e8; }
.creation-box h3, .save-conflict h3 { margin: 0 0 7px; color: #42224f; }
.creation-box label { display: block; font-weight: bold; }
.creation-box input { display: block; width: min(100%, 320px); min-height: 35px; margin: 4px 0 9px; padding: 5px 7px; border: 1px solid #857e6a; }
.creation-box > button { margin: 3px 0 7px; }
.class-choices { margin-top: 9px; }
.class-choices button { margin: 0 5px 5px 0; }
.conflict-details { font-weight: bold; }
.game-actions { margin-top: 8px; }
.boss-controls { margin-top: 12px; }
.boss-controls p { font-weight: bold; }
.connection-note[data-state="offline"] .status-dot { background: #c27758; }
.connection-note[data-state="online"] .status-dot { background: #6b9a5e; }
.connection-note[data-state="pending"] .status-dot { background: #d6ad49; }
.connection-note[data-state] { color: #4e493e; }
#auth-status.is-error { font-weight: normal; }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .site-shell { width: calc(100% - 18px); margin: 10px auto; }
  .masthead { padding: 18px 10px 14px; }
  .site-nav { gap: 6px 13px; }
  .paper { padding: 16px 15px; }
  .game-layout, .game-lower { grid-template-columns: 1fr; }
  .game-toolbar { justify-content: flex-start; }
  .compact-list { columns: 1; }
}

@media (max-width: 760px) {
  .page-layout { grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 10px; }
  .sidebar { position: static; }
  .sidebar-menu:not([open]) { display: block; }
  .sidebar-menu > summary { min-height: 44px; padding: 9px 12px; }
  .site-nav { grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 4px; padding: 2px 8px 9px; }
  .site-nav a { min-height: 44px; padding: 8px 9px; }
  .page-content main { gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
