* {
    box-sizing: border-box;
}

html,
body,
#app {
    width: 100%;
    height: 100%;
}

body {
    margin: 0;
    color: #f2e7c9;
    background: #11140f;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    overflow: hidden;
}

button,
input,
select,
textarea {
    font: inherit;
}

#app {
    position: relative;
}

#game-container {
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 0;
}

#game-container canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

.game-panel,
.dialogue-panel,
.intro-panel {
    position: fixed;
    z-index: 40;
    border: 2px solid #d8b764;
    background:
        linear-gradient(180deg, rgba(43, 34, 22, 0.96), rgba(16, 18, 20, 0.96));
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.game-hud {
    position: fixed;
    top: 18px;
    left: 18px;
    z-index: 20;
    display: flex;
    align-items: stretch;
    gap: 8px;
    color: #f6d982;
}

.game-hud > div {
    min-height: 38px;
    border: 2px solid #d8b764;
    background: rgba(17, 19, 24, 0.88);
    padding: 7px 10px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.36);
}

.game-hud strong {
    display: block;
    font-size: 13px;
    line-height: 1.1;
}

.game-hud span {
    display: block;
    color: #8bbd7a;
    font-size: 10px;
    line-height: 1.3;
    text-transform: uppercase;
}

.intro-panel {
    top: 50%;
    left: 50%;
    width: min(760px, calc(100vw - 36px));
    padding: 0;
    transform: translate(-50%, -50%);
    outline: 1px solid rgba(246, 217, 130, 0.32);
    outline-offset: -8px;
    overflow: hidden;
}

.intro-banner {
    display: block;
    width: 100%;
    max-height: 300px;
    object-fit: cover;
}

.intro-copy {
    padding: 18px 24px 24px;
    background: rgba(13, 15, 17, 0.74);
}

.intro-panel.is-hidden {
    display: none;
}

.camera-controls {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 45;
    display: grid;
    grid-template-columns: repeat(3, 32px);
    gap: 6px;
}

.game-panel {
    left: 18px;
    bottom: 18px;
    width: min(420px, calc(100vw - 36px));
    padding: 7px;
    transform: translateY(calc(100% + 24px));
    transition: transform 160ms ease-out;
}

.game-panel.is-visible {
    transform: translateY(0);
}

.selection-frame {
    min-height: 170px;
    padding: 16px;
    border: 1px solid rgba(216, 183, 100, 0.42);
    background: rgba(9, 11, 12, 0.48);
}

.selection-top {
    display: grid;
    grid-template-columns: 78px 1fr;
    gap: 14px;
    align-items: center;
}

.selection-avatar {
    width: 78px;
    height: 78px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(216, 183, 100, 0.5);
    background:
        radial-gradient(circle at 50% 35%, rgba(216, 183, 100, 0.16), transparent 58%),
        rgba(10, 12, 13, 0.78);
    overflow: hidden;
}

.selection-avatar img {
    max-width: 92%;
    max-height: 92%;
    object-fit: contain;
    image-rendering: pixelated;
    filter: drop-shadow(0 8px 5px rgba(0, 0, 0, 0.38));
}

.selection-progress {
    margin-top: 12px;
    padding: 8px;
    border: 1px solid rgba(90, 80, 55, 0.85);
    background: rgba(13, 16, 18, 0.7);
}

.selection-progress div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    color: #8bbd7a;
    font-size: 10px;
    text-transform: uppercase;
}

.selection-progress meter {
    width: 100%;
    height: 12px;
}

.selection-progress meter::-webkit-meter-bar {
    border: 1px solid #5a5037;
    background: #0d1014;
}

.selection-progress meter::-webkit-meter-optimum-value {
    background: linear-gradient(90deg, #8bbd7a, #f6d982);
}

.dialogue-panel {
    right: 18px;
    bottom: 18px;
    width: min(760px, calc(100vw - 36px));
    padding: 0;
    display: none;
    background: rgba(23, 20, 16, 0.96);
    z-index: 50;
}

.dialogue-panel.is-visible {
    display: block;
}

.dialogue-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border-bottom: 1px solid #5a5037;
    background: rgba(45, 35, 24, 0.82);
}

.dialogue-speaker {
    display: flex;
    align-items: center;
    gap: 14px;
}

.dialogue-speaker img {
    width: 56px;
    height: 64px;
    object-fit: contain;
    image-rendering: pixelated;
    filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.45));
}

.chat-log {
    height: min(330px, 42vh);
    margin: 16px 16px 0;
    padding: 14px;
    overflow-y: auto;
    border: 1px solid #5a5037;
    background: rgba(11, 14, 15, 0.76);
    scrollbar-color: #d8b764 #151211;
    scrollbar-width: thin;
}

.chat-log::-webkit-scrollbar {
    width: 10px;
}

.chat-log::-webkit-scrollbar-track {
    background: #151211;
    border-left: 1px solid #3e3425;
}

.chat-log::-webkit-scrollbar-thumb {
    background: #9d7f43;
    border: 2px solid #151211;
}

.chat-message {
    width: fit-content;
    max-width: 78%;
    margin: 0 0 10px;
    padding: 10px 12px;
    border: 1px solid rgba(216, 183, 100, 0.32);
    background: rgba(43, 34, 22, 0.82);
}

.chat-message.user {
    margin-left: auto;
    border-color: rgba(139, 189, 122, 0.42);
    background: rgba(25, 47, 33, 0.82);
}

.chat-message span {
    display: block;
    margin-bottom: 4px;
    color: #8bbd7a;
    font-size: 10px;
    text-transform: uppercase;
}

.chat-message p {
    margin: 0;
}

.chat-message.thinking p::after {
    content: "";
    display: inline-block;
    min-width: 1.2em;
    animation: dots 1s steps(4, end) infinite;
}

@keyframes dots {
    0% { content: ""; }
    25% { content: "."; }
    50% { content: ".."; }
    75%, 100% { content: "..."; }
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 16px 0;
}

.quick-actions button {
    border: 1px solid #5a5037;
    color: #f6d982;
    background: rgba(31, 37, 48, 0.9);
    padding: 7px 10px;
    cursor: pointer;
}

.quick-actions button:hover {
    border-color: #d8b764;
}

.panel-kicker {
    margin-bottom: 6px;
    color: #8bbd7a;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h2 {
    margin: 0;
    color: #f6d982;
    font-size: 20px;
}

h1 {
    margin: 0;
    color: #f6d982;
    font-size: 42px;
}

p {
    margin: 10px 0 0;
    color: #d4c7a4;
    font-size: 14px;
    line-height: 1.55;
}

.icon-button {
    width: 28px;
    height: 28px;
    border: 1px solid #5a5037;
    color: #f6d982;
    background: #1f2530;
    cursor: pointer;
}

.icon-button:hover,
.primary-action:hover,
#feedback-submit:hover,
#intro-enter:hover {
    filter: brightness(1.12);
}

button:disabled {
    cursor: wait;
    filter: grayscale(0.35) brightness(0.85);
}

.primary-action,
#feedback-submit,
#intro-enter {
    margin-top: 14px;
    border: 1px solid #d8b764;
    color: #1a1d16;
    background: #d8b764;
    padding: 9px 12px;
    cursor: pointer;
}

textarea,
input {
    width: 100%;
    border: 1px solid #5a5037;
    color: #f2e7c9;
    background: #0d1014;
    padding: 10px;
}

textarea:focus,
input:focus {
    outline: none;
    border-color: #d8b764;
    box-shadow: 0 0 0 2px rgba(216, 183, 100, 0.16);
}

textarea {
    display: block;
    width: calc(100% - 32px);
    margin: 14px 16px 0;
    resize: vertical;
}

.dialogue-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    margin: 10px 16px 0;
}

.feedback-status {
    min-height: 22px;
    margin: 10px 16px 16px;
    color: #8bbd7a;
    font-size: 12px;
}

.newspaper-overlay {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.42);
}

.newspaper-overlay.is-visible {
    display: flex;
}

.newspaper {
    position: relative;
    width: min(820px, calc(100vw - 40px));
    max-height: calc(100vh - 48px);
    overflow: auto;
    color: #2b2115;
    border: 2px solid #5c4526;
    background:
        linear-gradient(90deg, rgba(80, 55, 24, 0.12), transparent 18%, transparent 82%, rgba(80, 55, 24, 0.12)),
        #e6d0a2;
    box-shadow: 0 26px 70px rgba(0, 0, 0, 0.55);
    pointer-events: auto;
}

.newspaper-close {
    position: absolute;
    top: 12px;
    right: 12px;
    color: #2b2115;
    background: #d4b471;
}

.newspaper-masthead {
    padding: 24px 58px 18px;
    text-align: center;
    border-bottom: 4px double #5c4526;
}

.newspaper-masthead span {
    display: inline-block;
    margin-bottom: 8px;
    padding: 4px 10px;
    color: #f8e7bd;
    background: #9b2f26;
    font-size: 11px;
    text-transform: uppercase;
}

.newspaper-masthead h2 {
    color: #2b2115;
    font-size: 42px;
}

.newspaper-masthead p,
.newspaper-body p,
.newspaper-body li {
    color: #3e2f1d;
}

.newspaper-body {
    display: grid;
    grid-template-columns: 1.35fr 0.8fr;
    gap: 22px;
    padding: 22px 28px 28px;
}

.newspaper-body h3 {
    margin: 0 0 10px;
    color: #2b2115;
    font-size: 18px;
    text-transform: uppercase;
}

.newspaper-body ul {
    margin: 0;
    padding-left: 20px;
}

.newspaper-body li {
    margin-bottom: 8px;
    line-height: 1.45;
}

.newspaper-body li strong {
    color: #2b2115;
}

.newspaper-body aside {
    padding-left: 18px;
    border-left: 2px solid rgba(92, 69, 38, 0.45);
}

@media (max-width: 680px) {
    .dialogue-actions {
        grid-template-columns: 1fr;
    }

    .newspaper-body {
        grid-template-columns: 1fr;
    }
}
