:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --paper: #f5f2ec;
  --surface: #fffdf9;
  --ink: #1c252d;
  --muted: #68747d;
  --line: #ded9d0;
  --wine: #7b2d3d;
  --wine-soft: #f2e7e8;
  --navy: #183445;
  --gold: #bc8b45;
  --shadow: 0 18px 55px rgba(33, 42, 48, 0.09);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; overflow-x: hidden; color: var(--ink); background: var(--paper); }
button, input, textarea { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
.hidden { display: none !important; }

.loading-screen { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 1rem; color: var(--muted); }
.seal { width: 3.2rem; height: 3.2rem; display: inline-grid; place-items: center; border: 1px solid rgba(255,255,255,.45); border-radius: 50%; color: white; background: var(--wine); font-family: Georgia, serif; font-size: 1.45rem; }
.seal.small { width: 2.2rem; height: 2.2rem; font-size: 1rem; }

.login-layout { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(22rem, 0.9fr) minmax(28rem, 1.1fr); }
.login-intro { min-height: 100vh; min-height: 100dvh; padding: clamp(2rem, 5vw, 5rem); display: flex; flex-direction: column; justify-content: space-between; color: white; background: linear-gradient(145deg, rgba(24,52,69,.96), rgba(17,38,50,.98)), radial-gradient(circle at 15% 10%, #7b2d3d, transparent 25rem); }
.wordmark, .compact-wordmark { display: flex; align-items: center; gap: .85rem; font-weight: 700; }
.wordmark span:last-child { letter-spacing: .04em; }
.overline { margin: 0 0 .75rem; color: var(--wine); font-size: .72rem; font-weight: 850; letter-spacing: .15em; }
.login-intro .overline { color: #e5bd7d; }
.login-intro h1 { max-width: 9ch; margin: 0 0 1.5rem; font-family: Georgia, "Times New Roman", serif; font-size: clamp(3.2rem, 7vw, 6.5rem); font-weight: 500; line-height: .94; letter-spacing: -.045em; }
.intro-copy { max-width: 32rem; color: #d8e0e4; font-size: 1.05rem; line-height: 1.65; }
.location { margin: 0; color: #aebdc5; font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; }

.login-panel { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 2rem; }
.login-card { width: min(28rem, 100%); padding: clamp(1.5rem, 4vw, 2.5rem); border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); box-shadow: var(--shadow); }
.login-card h2 { margin: 0; font-family: Georgia, serif; font-size: 2.1rem; font-weight: 500; }
.form-help { margin: .6rem 0 2rem; color: var(--muted); line-height: 1.55; }
label { display: block; margin: 1rem 0 .45rem; color: #37434b; font-size: .83rem; font-weight: 750; }
input, textarea { width: 100%; border: 1px solid #cfc9c0; border-radius: .65rem; color: var(--ink); background: white; outline: none; }
input { min-height: 3.15rem; padding: .75rem .85rem; }
input:focus, textarea:focus { border-color: var(--wine); box-shadow: 0 0 0 3px rgba(123,45,61,.1); }
.password-row { position: relative; }
.password-row input { padding-right: 5.7rem; letter-spacing: .06em; }
.password-row button { position: absolute; top: .5rem; right: .45rem; bottom: .5rem; padding: 0 .65rem; border: 0; border-radius: .45rem; color: var(--wine); background: var(--wine-soft); font-size: .78rem; font-weight: 750; }
#code { text-transform: uppercase; letter-spacing: .28em; font-size: 1.15rem; font-weight: 800; text-align: center; }
.form-error { min-height: 1.4rem; margin: .7rem 0; color: #a51f37; font-size: .84rem; }
.submit-button { width: 100%; min-height: 3.2rem; border: 0; border-radius: .65rem; color: white; background: var(--wine); font-weight: 800; }
.submit-button:hover { background: #692331; }
.submit-button:disabled { opacity: .62; cursor: wait; }
.privacy-note { margin: 1rem 0 0; color: #8a938f; font-size: .75rem; text-align: center; }
.back-link { display: block; margin-top: 1.1rem; color: var(--muted); font-size: .8rem; text-align: center; text-decoration: none; }
.back-link:hover { color: var(--wine); text-decoration: underline; }

.player-header { position: sticky; top: 0; z-index: 20; height: 4.25rem; padding: 0 clamp(1rem, 3vw, 2.25rem); display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); background: rgba(255,253,249,.92); backdrop-filter: blur(14px); }
.compact-wordmark { color: var(--navy); text-decoration: none; }
.identity { display: flex; align-items: center; gap: .85rem; }
.identity > span { color: var(--muted); font-size: .85rem; }
.identity button { padding: .55rem .7rem; border: 1px solid var(--line); border-radius: .55rem; color: #4f5d65; background: transparent; }
.player-layout { width: min(76rem, 100%); margin: 0 auto; padding: 2.25rem clamp(1rem, 3vw, 2rem) 5rem; display: grid; grid-template-columns: 14rem minmax(0, 1fr); gap: clamp(2rem, 5vw, 4.5rem); }
.player-content { min-width: 0; }
.player-nav { position: sticky; top: 6.5rem; align-self: start; }
.role-summary { padding-bottom: 1.3rem; border-bottom: 1px solid var(--line); }
.role-summary strong, .role-summary small { display: block; }
.role-summary strong { margin: .75rem 0 .2rem; font-family: Georgia, serif; font-size: 1.4rem; font-weight: 500; }
.role-summary small { color: var(--muted); }
.confidential { display: inline-block; padding: .25rem .45rem; border-radius: 100vmax; color: var(--wine); background: var(--wine-soft); font-size: .67rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.player-nav nav { display: grid; gap: .2rem; margin: 1.25rem 0; }
.tab-button { min-height: 2.75rem; padding: .65rem .7rem; border: 0; border-radius: .5rem; color: #5c6971; background: transparent; text-align: left; }
.tab-button:hover, .tab-button.active { color: var(--wine); background: var(--wine-soft); font-weight: 750; }
.tab-icon, .tab-label-short, .logout-short { display: none; }
.section-nav { display: grid; gap: .15rem; padding-left: .7rem; border-left: 1px solid var(--line); }
.section-nav a { padding: .38rem .5rem; color: #7b858c; font-size: .75rem; line-height: 1.3; text-decoration: none; }
.section-nav a:hover { color: var(--wine); }
.content-view { display: none; }
.content-view.active { display: block; }
.role-heading { margin-bottom: 2rem; padding: 2rem clamp(1.4rem, 4vw, 3rem); border-radius: 1rem; color: white; background: var(--navy); }
.role-heading.compact { background: #334b59; }
.role-heading .overline { color: #e7bd7c; }
.role-heading h1 { margin: 0 0 .9rem; overflow-wrap: break-word; font-family: Georgia, serif; font-size: clamp(2.5rem, 5vw, 4.6rem); font-weight: 500; line-height: 1.02; letter-spacing: -.03em; }
.role-heading p:last-child { max-width: 48rem; margin: 0; color: #d4dee3; line-height: 1.6; }
.section-stack { display: grid; gap: 1rem; }
.sheet-section { scroll-margin-top: 5.5rem; padding: clamp(1.25rem, 3vw, 2rem); border: 1px solid var(--line); border-radius: .9rem; background: var(--surface); box-shadow: 0 8px 30px rgba(33,42,48,.045); }
.section-number { width: 2rem; height: 2rem; display: inline-grid; place-items: center; border-radius: 50%; color: var(--wine); background: var(--wine-soft); font-size: .75rem; font-weight: 850; }
.sheet-section h2 { margin: .8rem 0 1rem; font-family: Georgia, serif; font-size: clamp(1.45rem, 3vw, 2rem); font-weight: 500; }
.sheet-section p, .sheet-section li { color: #445159; font-size: .98rem; line-height: 1.68; }
.sheet-section p:last-child, .sheet-section ul:last-child, .sheet-section ol:last-child { margin-bottom: 0; }
.sheet-section ul, .sheet-section ol { padding-left: 1.35rem; }
.sheet-section li { margin: .55rem 0; padding-left: .2rem; }
.sheet-section strong { color: #202b31; }
.sheet-section code { padding: .12rem .3rem; border-radius: .25rem; color: var(--wine); background: var(--wine-soft); }
.sheet-section a { display: inline-flex; min-height: 2.7rem; align-items: center; margin-top: .35rem; padding: .65rem .9rem; border-radius: .55rem; color: #fff; background: var(--wine); font-weight: 750; text-decoration: none; }
.sheet-section a:hover { background: #642331; }
.sheet-section a:focus-visible { outline: 3px solid rgba(123,45,61,.25); outline-offset: 2px; }
.notes-card { padding: clamp(1.25rem, 3vw, 2rem); border: 1px solid var(--line); border-radius: .9rem; background: var(--surface); }
.notes-card label { margin-top: 0; }
.notes-card textarea { min-height: 20rem; padding: 1rem; resize: vertical; line-height: 1.6; }
.notes-card span { display: block; margin-top: .6rem; color: var(--muted); font-size: .75rem; }

@media (max-width: 1040px) and (min-width: 821px) {
  .player-layout { grid-template-columns: 12rem minmax(0, 1fr); gap: 2rem; }
  .role-heading h1 { font-size: clamp(2.7rem, 5vw, 3.8rem); }
}

@media (max-width: 900px) {
  .login-layout { grid-template-columns: 1fr; }
  .login-intro { min-height: auto; padding: max(1.5rem, env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right)) 3.25rem max(1.25rem, env(safe-area-inset-left)); gap: 2.75rem; }
  .login-intro h1 { max-width: 11ch; margin: 0 0 1rem; font-size: clamp(3rem, 10vw, 5rem); }
  .intro-copy { margin-bottom: 0; font-size: .98rem; }
  .location { margin-top: .5rem; }
  .login-panel { min-height: auto; padding: 0 1rem max(2rem, env(safe-area-inset-bottom)); align-items: start; }
  .login-card { margin-top: -1.75rem; }
}

@media (max-width: 820px) {
  .player-header { min-height: 4rem; height: auto; padding: .55rem max(1rem, env(safe-area-inset-right)) .55rem max(1rem, env(safe-area-inset-left)); }
  .compact-wordmark { gap: .6rem; min-width: 0; font-size: .88rem; }
  .compact-wordmark span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .identity > span { display: none; }
  .identity { flex: 0 0 auto; }
  .identity button { min-height: 2.7rem; padding-inline: .8rem; }
  .logout-long { display: none; }
  .logout-short { display: inline; }
  .player-layout { display: block; width: min(46rem, 100%); padding: 1rem max(1rem, env(safe-area-inset-right)) calc(6rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); }
  .player-nav { position: fixed; inset: auto 0 0; z-index: 30; margin: 0; padding: .45rem max(.75rem, env(safe-area-inset-right)) max(.45rem, env(safe-area-inset-bottom)) max(.75rem, env(safe-area-inset-left)); border-top: 1px solid var(--line); background: rgba(255,253,249,.96); box-shadow: 0 -12px 35px rgba(33,42,48,.08); backdrop-filter: blur(14px); }
  .role-summary { display: none; }
  .player-nav nav { width: min(30rem, 100%); grid-template-columns: repeat(3, 1fr); gap: .25rem; margin: 0 auto; }
  .tab-button { min-height: 3.3rem; padding: .35rem .2rem; display: grid; place-content: center; justify-items: center; gap: .12rem; text-align: center; font-size: .72rem; }
  .tab-icon { display: block; font-size: 1.05rem; line-height: 1; }
  .tab-label-wide { display: none; }
  .tab-label-short { display: inline; }
  .section-nav { display: none; }
  .role-heading { margin-bottom: .85rem; padding: clamp(1.25rem, 5vw, 2rem); border-radius: .85rem; }
  .role-heading h1 { font-size: clamp(2.15rem, 9vw, 3.5rem); }
  .section-stack { gap: .75rem; }
  .sheet-section { scroll-margin-top: 5rem; padding: clamp(1.15rem, 4.5vw, 1.75rem); }
  .sheet-section h2 { font-size: clamp(1.35rem, 5.5vw, 1.8rem); }
  .sheet-section p, .sheet-section li { font-size: 1rem; line-height: 1.62; }
  .notes-card textarea { min-height: 45vh; }
}

@media (max-width: 420px) {
  .login-intro { padding-inline: 1rem; gap: 2rem; }
  .login-intro h1 { font-size: clamp(2.55rem, 13vw, 3.35rem); }
  .intro-copy { font-size: .9rem; line-height: 1.55; }
  .location { font-size: .74rem; }
  .login-panel { padding-inline: .75rem; }
  .login-card { padding: 1.25rem; }
  .login-card h2 { font-size: 1.75rem; }
  .form-help { margin-bottom: 1.4rem; }
  input, textarea { font-size: 1rem; }
  .compact-wordmark span:last-child { max-width: 9.5rem; }
  .player-layout { padding-inline: .65rem; }
  .role-heading, .sheet-section, .notes-card { border-radius: .75rem; }
  .role-heading p:last-child { font-size: .9rem; }
}

@media (max-width: 340px) {
  .compact-wordmark span:last-child { display: none; }
  .identity button { padding-inline: .65rem; }
  .player-layout { padding-inline: .5rem; }
}

@media (max-height: 560px) and (min-width: 640px) {
  .login-layout { grid-template-columns: minmax(18rem, .9fr) minmax(22rem, 1.1fr); }
  .login-intro, .login-panel { min-height: 100vh; min-height: 100dvh; }
  .login-intro { padding: 1.25rem 1.75rem; gap: 1rem; }
  .login-intro h1 { margin-bottom: .75rem; font-size: clamp(2.5rem, 7vw, 4rem); }
  .intro-copy { font-size: .86rem; line-height: 1.45; }
  .login-panel { padding: 1rem; align-items: center; }
  .login-card { margin: 0; padding: 1.25rem; }
  .form-help { margin-bottom: 1rem; }
}
