/* RD-01 shared viewport and approved components. Feature layouts retain their own owners. */
@font-face { font-family: Cinzel; src: url('../assets/ui/foundation/fonts/Cinzel-variable.ttf') format('truetype'); font-weight: 400 900; font-display: swap; }
:root {
  --bg: #0a121b; --panel: #101b25; --panel2: #14222c; --line: #806744;
  --text: #f1e7d2; --muted: #b6ad9e; --gold: #e7bf75; --cyan: #40dbea;
  --font: Georgia, 'Times New Roman', serif; --display-font: Cinzel, Georgia, serif;
  --app-height: 100dvh; --app-width: 100%;
}
html, body { width: 100%; height: 100%; min-width: 0; overflow: hidden; }
body { background: #0a121b url('../assets/ui/foundation-stone.png') repeat; background-size: 627px; font: 15px/1.45 var(--font); }
.screen { height: var(--app-height); min-height: 0; max-width: 100%; display: flex; flex-direction: column; overflow: hidden; }
.screen > * { min-width: 0; }
.topbar, .site-nav { flex: 0 0 auto; background: #0a141ed9; border-bottom: 1px solid var(--gold); box-shadow: 0 2px 0 #513d26, 0 3px 0 #060a0e; }
.topbar { flex-wrap: wrap; gap: 8px 12px; padding: 8px 14px; }
.foundation-brand { display: inline-flex; align-items: center; flex: 0 0 auto; }
.foundation-brand img { display: block; width: 180px; height: 54px; object-fit: contain; }
.logo-small { font-family: var(--display-font); letter-spacing: .5px; }
#tabs { order: 10; flex: 1 1 100%; min-width: 0; gap: 4px; }
.tab { font-size: 14px; border-width: 1px; padding: 5px 9px; }
.tab.active { color: #fff3d6; border-color: var(--gold); box-shadow: inset 0 0 10px #d1a44726; }
.layout { flex: 1 1 auto; height: auto; min-height: 0; min-width: 0; grid-template-columns: minmax(190px, 240px) minmax(0, 1fr) minmax(240px, 300px); padding: 12px; gap: 12px; overflow: hidden; }
.layout > * { min-width: 0; min-height: 0; overflow: auto; overscroll-behavior: contain; }
#center { position: relative; }
#right { overflow: hidden; }
#site-main { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.site-foot { flex: 0 0 auto; }
#scr-chars > .panel { flex: 1 1 auto; min-height: 0; overflow: auto; }
/* Temporary bounded panels until their individual cards implement paging/detail views. */
.panel { border: 1px solid var(--line); background: #101a24d9; box-shadow: inset 0 0 0 2px #050a0b, 0 2px 8px #0005; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
input, textarea, select { color: var(--text); background-color: #0a141e; border-color: var(--line); }
.btn { border: 1px solid #b18a4b; background: linear-gradient(#293039, #111923); color: var(--text); box-shadow: inset 0 0 0 1px #080d13, 0 3px 5px #0006; }
.btn.primary { border-color: #f2ce8b; background: linear-gradient(#b58232, #604011); color: #fff5db; }
.btn:disabled { opacity: .5; }
.btn:hover:not(:disabled) { border-color: #fff0bc; }
.foundation-icon { display: inline-block; width: 1.2em; height: 1.2em; flex: 0 0 auto; vertical-align: -.18em; background: currentColor; mask: var(--icon) center / contain no-repeat; }
.icon-game { --icon: url('../assets/ui/foundation/controller.svg'); }
.icon-hero { --icon: url('../assets/ui/foundation/person-badge.svg'); }
.icon-chat { --icon: url('../assets/ui/foundation/chat-dots.svg'); }
.icon-send { --icon: url('../assets/ui/foundation/send.svg'); }
.icon-close { --icon: url('../assets/ui/foundation/x-lg.svg'); }
.icon-warning { --icon: url('../assets/ui/foundation/exclamation-triangle.svg'); }
.icon-empty { --icon: url('../assets/ui/foundation/journal-text.svg'); }
.icon-retry { --icon: url('../assets/ui/foundation/arrow-clockwise.svg'); }
.icon-back { --icon: url('../assets/ui/foundation/chevron-left.svg'); }
.icon-global { --icon: url('../assets/ui/foundation/globe.svg'); }
.icon-zone { --icon: url('../assets/ui/foundation/geo-alt-fill.svg'); }
.icon-guild { --icon: url('../assets/ui/foundation/shield-shaded.svg'); }
.icon-whisper { --icon: url('../assets/ui/foundation/envelope-fill.svg'); }
.icon-game, .icon-hero, .icon-chat, .icon-empty { mask: none; background: url('../assets/ui/foundation-symbols.png') no-repeat; background-size: 500% auto; }
.icon-game { background-position: 1.859% 48.791%; }
.icon-hero { background-position: 26.203% 46.547%; }
.icon-chat { background-position: 49.971% 51.899%; }
.icon-empty { background-position: 74.373% 48.791%; width: 120px; height: 120px; }
.foundation-surface { position: relative; color: var(--text); background: #0b1621 url('../assets/ui/foundation-stone.png') repeat; background-size: 627px; border: 1px solid #e5bf78; border-radius: 2px; box-shadow: inset 0 0 0 3px #0b1116, inset 0 0 0 4px #866b42, 0 8px 24px #0008; clip-path: polygon(12px 0,calc(100% - 12px) 0,100% 12px,100% calc(100% - 12px),calc(100% - 12px) 100%,12px 100%,0 calc(100% - 12px),0 12px); }
.foundation-ornament { display: block; margin: -16px auto 0; width: 135px; height: 32px; background: linear-gradient(90deg, transparent, #40dbea, transparent) center / 135px 1px no-repeat; }
.foundation-ornament > i { display: block; width: 60px; height: 32px; margin: auto; background: url('../assets/ui/foundation-symbols.png') 99.148% 48.101% / 500% auto no-repeat; }
.foundation-chat-empty > .foundation-ornament, .foundation-banner .foundation-ornament, [data-theme='industry'] > .foundation-ornament { display: none; }
.foundation-surface::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(135deg,transparent 8px,#e5bf78 8px 9px,transparent 9px) top left, linear-gradient(225deg,transparent 8px,#e5bf78 8px 9px,transparent 9px) top right, linear-gradient(315deg,transparent 8px,#e5bf78 8px 9px,transparent 9px) bottom right, linear-gradient(45deg,transparent 8px,#e5bf78 8px 9px,transparent 9px) bottom left; background-size: 12px 12px; background-repeat: no-repeat; }
.foundation-state { text-align: center; padding: 22px 28px; width: min(100%, 520px); min-height: 280px; margin: auto; }
.foundation-state h2, .foundation-dialog h2 { font-family: Georgia, serif; font-weight: 600; color: #f5e7c3; font-size: clamp(22px, 2vw, 30px); letter-spacing: 0; line-height: 1.25; border: 0; margin: 10px 0 22px; padding: 0; }
.foundation-state h2 { font-size: 32px; margin: 8px 0 16px; }
.foundation-state p { margin: 12px 0 0; font-size: 24px; line-height: 1.3; overflow-wrap: anywhere; }
.foundation-state-mark { color: var(--gold); font-size: 52px; line-height: 1; }
.foundation-spinner { display: inline-block; width: 112px; height: 112px; border: 6px solid #ad8951; border-right-color: #3cdeef; border-bottom-color: #3cdeef; border-radius: 50%; box-shadow: inset 0 0 0 1px #f5de9b, 0 0 12px #39d7eb40; animation: foundation-spin 1.2s linear infinite; }
@keyframes foundation-spin { to { transform: rotate(360deg); } }
.foundation-state[data-state='error'] .foundation-state-mark, .foundation-state[data-state='reconnecting'] .foundation-state-mark { color: #ff776a; font-size: 26px; }
.foundation-state[data-state='error'] p, .foundation-state[data-state='reconnecting'] p { display: flex; align-items: center; justify-content: center; gap: 16px; color: #fff0df; border: 1px solid #ce584c; background: #471d1d99; padding: 10px; margin-top: 10px; }
.foundation-state[data-state='error'] p, .foundation-state[data-state='reconnecting'] p { max-width: 410px; margin-left: auto; margin-right: auto; }
.foundation-retry { margin-top: 22px; width: min(100%, 324px); min-height: 50px; padding: 8px 20px; display: inline-flex; align-items: center; justify-content: center; gap: 18px; font-size: 24px; }
.foundation-state[data-state='empty'] .foundation-state-mark { position: relative; margin: 8px auto; width: 100%; }
.foundation-state[data-state='empty'] .foundation-state-mark::before,
.foundation-state[data-state='empty'] .foundation-state-mark::after { content: ''; position: absolute; top: 50%; width: 26%; height: 1px; background: linear-gradient(90deg, transparent, #d9b774); }
.foundation-state[data-state='empty'] .foundation-state-mark::before { left: 0; }
.foundation-state[data-state='empty'] .foundation-state-mark::after { right: 0; transform: rotate(180deg); }
.foundation-state .btn, .foundation-dialog .btn, .foundation-state[data-state='error'] p,
.foundation-state[data-state='reconnecting'] p { clip-path: polygon(8px 0,calc(100% - 8px) 0,100% 8px,100% calc(100% - 8px),calc(100% - 8px) 100%,8px 100%,0 calc(100% - 8px),0 8px); }
.foundation-state .btn:focus-visible, .foundation-dialog .btn:focus-visible { border-color: var(--cyan); box-shadow: inset 0 0 0 2px var(--cyan), 0 0 12px var(--cyan); }
.foundation-state .btn::after, .foundation-dialog .btn::after,
body[data-mobile="true"] .ctab::after, body[data-mobile="true"] .mob-bar button::after,
body[data-mobile="true"] .mob-back::after, body[data-mobile="true"] #chat-form .btn::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(135deg,transparent 5px,#dabb7a 5px 6px,transparent 6px) top left, linear-gradient(225deg,transparent 5px,#dabb7a 5px 6px,transparent 6px) top right, linear-gradient(315deg,transparent 5px,#dabb7a 5px 6px,transparent 6px) bottom right, linear-gradient(45deg,transparent 5px,#dabb7a 5px 6px,transparent 6px) bottom left; background-size: 8px 8px; background-repeat: no-repeat; }
#foundation-connection { padding: 12px 0; }
.foundation-banner { flex: 0 0 auto; padding: 4px 12px !important; }
.foundation-banner .foundation-state { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 0; padding: 6px 12px; }
.foundation-banner .foundation-state h2 { font-size: 16px; margin: 0; }
.foundation-banner .foundation-state-mark { display: none; }
.foundation-banner .foundation-state::before { display: none; }
.foundation-banner .foundation-state p { font-size: 14px; margin: 0; padding: 0; border: 0; background: none; flex: 1; clip-path: none; }
.foundation-banner .foundation-retry { font-size: 15px; width: auto; min-height: 36px; padding: 4px 12px; margin: 0; }
.foundation-banner .foundation-retry .foundation-icon { display: none; }
.foundation-bootstrap { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px !important; }
.foundation-state[data-theme='industry'] { --font: system-ui, sans-serif; font-family: var(--font); border-color: #bd9b68; background-color: #0d2130; }
.foundation-state[data-theme='industry'] h2 { font: 600 23px/1.3 system-ui, sans-serif; }
.foundation-state[data-theme='industry'] .btn { border-color: #35d9ce; }
.foundation-state[data-theme='industry'] { clip-path: none; border-radius: 10px; }
.foundation-state[data-theme='industry']::before, .foundation-state[data-theme='industry']::after { display: none; }
.foundation-state[data-theme='industry'] .icon-empty { width: 52px; height: 52px; color: var(--text); mask: var(--icon) center / contain no-repeat; background: currentColor; }
.foundation-dialog { position: fixed; inset: 0; height: fit-content; margin: auto; width: min(405px, calc(100% - 32px)); max-height: calc(var(--app-height) - 32px); padding: 20px; text-align: center; overflow: auto; }
.foundation-dialog::backdrop { background: #03070bb8; backdrop-filter: blur(2px); }
.foundation-dialog h2 { font-size: 26px; margin: 4px 18px 8px; padding-bottom: 6px; border-bottom: 1px solid #806744; }
.foundation-dialog p { margin: 0; font-size: 20px; line-height: 1.4; white-space: pre-line; overflow-wrap: anywhere; }
.foundation-close { position: absolute; right: 12px; top: 12px; width: 34px; height: 34px; padding: 5px; display: grid; place-items: center; }
.foundation-close .foundation-icon { width: 18px; height: 18px; }
.foundation-dialog-actions { display: flex; gap: 16px; margin-top: 16px; }
.foundation-dialog-actions .btn { flex: 1; min-width: 0; min-height: 44px; font-size: 19px; padding: 6px; overflow-wrap: anywhere; }
.chat { background: #101a24eb; }
#chat-form { display: flex; flex: 0 0 auto; gap: 8px; align-items: center; min-width: 0; }
#chat-input { flex: 1; min-width: 0; border-radius: 3px; }
#chat-form button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; min-height: 38px; }
#chat-form > .foundation-icon, .ctab > .foundation-icon { display: none; }
#chat-log { flex: 1 1 auto; min-height: 0; line-height: 1.55; }
#chat-log:empty { display: none; }
.chat-tabs { flex-wrap: wrap; flex: 0 0 auto; }
.ctab { padding: 5px 8px; font-size: 13px; }
.ctab.active { color: #d9ffff; border-color: var(--cyan); box-shadow: inset 0 0 8px #3bd8e033; }
.foundation-chat-empty { flex: 1 1 auto; min-height: 0; overflow: auto; width: 100%; max-width: 100%; margin: 10px 0; padding: 16px 10px; border-color: #655c48; display: flex; flex-direction: column; justify-content: safe center; }
.foundation-chat-empty h2 { font-size: 18px; margin: 4px 0 12px; }
.foundation-chat-empty p { font-size: 14px; margin-top: 10px; }
.foundation-chat-empty .foundation-state-mark { font-size: 30px; }
.foundation-chat-empty .icon-empty { width: 64px; height: 64px; }
.mob-bar { background: #091520; }
.mob-bar button { font-family: var(--font); color: var(--text); background: #101c28; border: 1px solid #675b45; border-radius: 4px; }
.mob-bar button.active { color: #d9ffff; border-color: var(--cyan); background: #17313e; box-shadow: inset 0 0 10px #40dbea26; }
.mob-bar button.active .foundation-icon { color: var(--cyan); }
.mob-bar .foundation-icon { color: var(--gold); }
body[data-mobile="true"][data-connection]:not([data-connection="ready"]) #scr-game { grid-template-rows: auto auto minmax(0, 1fr) auto; }
body[data-mobile="true"][data-keyboard="true"][data-connection]:not([data-connection="ready"]) #scr-game { grid-template-rows: auto auto minmax(0, 1fr); }
body[data-mobile="true"] .foundation-brand img { width: clamp(116px, 35vw, 145px); height: 48px; }
body[data-mobile="true"] .lang-slot button { min-height: 44px; min-width: 44px; }
body[data-mobile="true"] .foundation-close { width: 44px; }
body[data-mobile="true"] .lang-slot button { font: 16px/1.2 var(--font); background: none; border-color: transparent; }
body[data-mobile="true"] .lang-slot button.active { border-color: var(--gold); background: #55421c; }
body[data-mobile="true"] .mob-back { font-size: 18px; padding: 6px 14px; }
body[data-mobile="true"] .ctab { position: relative; font-size: 16px; background: linear-gradient(#1b2934, #0d1822); }
body[data-mobile="true"] .ctab > .foundation-icon { display: inline-block; width: 24px; height: 24px; margin-right: 6px; color: var(--gold); vertical-align: middle; }
body[data-mobile="true"] .ctab > .icon-chat { width: 32px; height: 32px; margin: -4px 2px -4px 0; }
body[data-mobile="true"] #chat-form > .foundation-icon { display: inline-block; width: 32px; height: 32px; }
body[data-mobile="true"] .mob-back .foundation-icon { width: 14px; height: 18px; margin-right: 6px; }
body[data-mobile="true"] #scr-game { border: 2px solid var(--gold); box-shadow: inset 0 0 0 2px #806744; clip-path: polygon(10px 0,calc(100% - 10px) 0,100% 10px,100% calc(100% - 10px),calc(100% - 10px) 100%,10px 100%,0 calc(100% - 10px),0 10px); }
body[data-mobile="true"] #scr-game::after { content: ''; position: absolute; z-index: 50; inset: 0; pointer-events: none; background: linear-gradient(135deg,transparent 6px,#e5bf78 6px 8px,transparent 8px) top left, linear-gradient(225deg,transparent 6px,#e5bf78 6px 8px,transparent 8px) top right, linear-gradient(315deg,transparent 6px,#e5bf78 6px 8px,transparent 8px) bottom right, linear-gradient(45deg,transparent 6px,#e5bf78 6px 8px,transparent 8px) bottom left; background-size: 10px 10px; background-repeat: no-repeat; }
body[data-mobile="true"] #chat-log { font-size: 18px; line-height: 1.35; border: 1px solid #897449; padding: 2px 10px; margin: 4px 0 6px; }
body[data-mobile="true"] .mob-bar button { font-size: 18px; border-color: #b38e50; background: linear-gradient(#24313b, #101c28); }
body[data-mobile="true"] .mob-bar .foundation-icon { width: 40px; height: 40px; margin: -6px 0; }
body[data-mobile="true"] .mob-bar button.active, body[data-mobile="true"] .ctab.active { border-color: var(--cyan); background: #10303b; box-shadow: inset 0 0 0 1px #40dbea80, inset 0 0 14px #40dbea26; }
body[data-mobile="true"] .ctab, body[data-mobile="true"] .mob-bar button, body[data-mobile="true"] .mob-back, body[data-mobile="true"] #chat-form .btn { clip-path: polygon(7px 0,calc(100% - 7px) 0,100% 7px,100% calc(100% - 7px),calc(100% - 7px) 100%,7px 100%,0 calc(100% - 7px),0 7px); }
body[data-mobile="true"] .ctab:focus-visible, body[data-mobile="true"] .mob-bar button:focus-visible, body[data-mobile="true"] .mob-back:focus-visible, body[data-mobile="true"] #chat-form .btn:focus-visible { border-color: var(--cyan); box-shadow: inset 0 0 0 2px var(--cyan); }
body[data-mobile="true"] .topbar .mob-back { margin-left: auto; }
body[data-mobile="true"] .foundation-dialog h2 { font-size: 24px; }
body[data-mobile="true"] .foundation-dialog-actions { gap: 12px; }
body[data-mobile="true"] .foundation-dialog-actions .btn { font-size: 18px; }
body[data-mobile="true"] .foundation-banner .foundation-state { gap: 8px; }
body[data-mobile="true"] .foundation-banner h2 { display: none; }
body[data-mobile="true"][data-keyboard="true"] .foundation-chat-empty { margin: 2px 0; padding: 2px 8px; }
body[data-mobile="true"][data-keyboard="true"] .foundation-chat-empty h2 { font: 14px/1.2 var(--font); margin: 0; }
body[data-mobile="true"][data-keyboard="true"] .foundation-chat-empty p,
body[data-mobile="true"][data-keyboard="true"] .foundation-chat-empty .foundation-state-mark { display: none; }
body[data-mobile="true"][data-keyboard="true"] #chat-log { margin: 2px 0; padding: 0 6px; font-size: 16px; line-height: 1.25; }
body[data-mobile="true"][data-keyboard="true"] .ctab > .foundation-icon { width: 20px; height: 20px; margin: 0 6px 0 0; }
body[data-mobile="true"][data-keyboard="true"][data-connection]:not([data-connection="ready"]) .chat-tabs,
body[data-mobile="true"][data-keyboard="true"][data-connection]:not([data-connection="ready"]) .foundation-chat-empty { display: none; }
#tab-ind { font-family: system-ui, sans-serif; }
@media (min-width: 761px) and (max-width: 1100px) {
  .layout { display: grid; grid-template-columns: minmax(150px, 190px) minmax(0, 1fr) minmax(200px, 240px); }
  #right { height: auto; }
}
@media (max-width: 600px) {
  body[data-mobile="true"] .mob-back { width: 44px; min-width: 44px; padding: 8px; }
  body[data-mobile="true"] .mob-back .foundation-icon { margin: 0; }
  body[data-mobile="true"] .mob-back [data-i18n] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  body[data-mobile="true"] .mob-bar button { flex-direction: column; gap: 0; min-height: 64px; font-size: 16px; }
  body[data-mobile="true"] .mob-bar .foundation-icon { width: 36px; height: 30px; margin: 0; }
}
@media (prefers-reduced-motion: reduce) { .foundation-spinner { animation: none; } }
