/* Beagle Bros aesthetic: warm parchment, black ink, Victorian woodcut feel */
/* Mobile-first: design for phones, scale up for desktop */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #f5f0e8;
    --bg-light: #ebe5d8;
    --line: #1a1a1a;
    --line-bright: #555;
    --text: #1a1a1a;
    --text-bright: #000;
    --accent: #8b2500;
    --accent-hover: #a63000;
    --error: #c0392b;
    --success: #2d6a4f;
    --tile-bg: #fff;
    --tile-border: #1a1a1a;
}

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: 'Courier New', Courier, monospace;
    font-size: clamp(16px, 2.5vw, 22px);
    overflow: hidden;
}

/* Screens */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hidden {
    display: none !important;
}

.center-content {
    text-align: center;
    width: 100%;
    padding: 2rem;
    overflow-y: auto;
    max-height: 100%;
}

/* Typography */
.title {
    font-size: clamp(3rem, 10vw, 7rem);
    letter-spacing: 0.2em;
    color: var(--text-bright);
    line-height: 1.1;
    margin-bottom: 0.5rem;
    border: 4px double var(--line);
    padding: 1.5rem 2rem;
    display: inline-block;
}

.subtitle {
    color: var(--line-bright);
    font-size: clamp(1rem, 3vw, 1.5rem);
    margin-bottom: 3rem;
    letter-spacing: 0.15em;
}

h2 {
    font-size: clamp(2rem, 6vw, 3rem);
    letter-spacing: 0.2em;
    color: var(--text-bright);
    border-bottom: 2px solid var(--line);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

/* Buttons */
.btn {
    font-family: inherit;
    font-size: clamp(1.1rem, 3vw, 1.5rem);
    padding: 1rem 2.5rem;
    border: 2px solid var(--line);
    cursor: pointer;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--accent);
    color: #f5f0e8;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-secondary {
    background: transparent;
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--bg-light);
    border-color: var(--text-bright);
    color: var(--text-bright);
}

#btn-next-round {
    margin-top: 1.5rem;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Landing screen */
.landing-buttons {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
}

.btn-landing {
    width: 100%;
    max-width: 24rem;
    padding: 1.5rem 2rem;
    font-size: clamp(1.3rem, 4vw, 2rem);
}

#landing-character {
    margin-top: 2rem;
}

/* Host/Join setup forms */
.setup-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
}

.btn-back {
    background: transparent;
    border: none;
    color: var(--line-bright);
    font-family: inherit;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    padding: 0.6rem 1.5rem;
    cursor: pointer;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.btn-back:hover {
    color: var(--text-bright);
}

.pin-input {
    font-family: inherit;
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    width: clamp(5rem, 20vw, 8rem);
    text-align: center;
    padding: 0.75rem;
    background: #fff;
    border: 2px solid var(--line);
    color: var(--text-bright);
    letter-spacing: 0.3em;
}

.name-input {
    font-family: inherit;
    font-size: clamp(1.2rem, 4vw, 1.8rem);
    width: 100%;
    max-width: 20rem;
    text-align: center;
    padding: 0.75rem 1rem;
    background: #fff;
    border: 2px solid var(--line);
    color: var(--text-bright);
    letter-spacing: 0.15em;
}

.name-input::placeholder {
    color: #999;
}

.name-input:focus {
    outline: none;
    border-color: var(--accent);
}

.pin-input::placeholder {
    color: #999;
}

.error-text {
    color: var(--error);
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    margin-top: 1rem;
    min-height: 1.5em;
}

/* Lobby */
.pin-display {
    font-size: clamp(2rem, 8vw, 4rem);
    color: var(--text-bright);
    letter-spacing: 0.3em;
    margin-bottom: 2rem;
}

.pin-display span {
    color: var(--accent);
}

.lobby-share {
    margin-bottom: 1.5rem;
}

.btn-copy {
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    padding: 0.75rem 1.5rem;
}

.player-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.player-item {
    padding: 0.75rem 1.25rem;
    border: 2px solid var(--line);
    color: var(--text);
    font-size: clamp(1rem, 3vw, 1.4rem);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-item .host-badge {
    color: var(--accent);
    font-size: clamp(0.8rem, 2vw, 1rem);
}

.subtle-text {
    color: var(--line-bright);
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
}

/* Game info overlay (top-left, shown during gameplay) */
.game-info {
    position: fixed;
    top: 0.5rem;
    left: 0.75rem;
    z-index: 100;
    font-size: clamp(0.75rem, 2vw, 0.95rem);
    color: var(--line-bright);
    letter-spacing: 0.1em;
    line-height: 1.4;
}

.game-info-name {
    font-weight: bold;
}

.game-info-pin {
    margin-left: 0.4em;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dashed;
    text-underline-offset: 0.2em;
}

.game-info-pin:hover {
    color: var(--text-bright);
}

/* Answering screen */
.game-layout {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 0.5rem;
}

.prompt-character-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.prompt-character-row .timer {
    flex-shrink: 0;
}

#prompt-character {
    flex: 1;
    min-width: 0;
}

.prompt-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border: 2px solid var(--line);
    background: var(--bg-light);
}

.prompt-text {
    font-size: clamp(1.1rem, 3.5vw, 1.8rem);
    color: var(--text-bright);
    font-style: italic;
    margin: 1.5rem 0;
}

.timer {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    color: var(--accent);
    font-weight: bold;
    min-width: 2.5rem;
    text-align: right;
}

.answer-area {
    flex: 1;
    min-height: 80px;
    border: 2px dashed var(--line);
    padding: 1rem;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 0.5rem;
    position: relative;
}

.answer-area .area-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #999;
    pointer-events: none;
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
}

.answer-area.has-tiles .area-label {
    display: none;
}

.helper-pool {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
}

.helper-pool .helper-tile {
    opacity: 0.6;
    font-size: clamp(0.85rem, 2vw, 1rem) !important;
    padding: 0.3rem 0.7rem !important;
    border-style: dashed !important;
}

.answer-area .helper-tile {
    border-style: solid !important;
    opacity: 1;
}

.word-pool {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem;
    border: 2px solid var(--line);
    background: var(--bg-light);
    min-height: 80px;
}

.word-tile {
    padding: 0.6rem 1rem;
    background: var(--tile-bg);
    border: 2px solid var(--tile-border);
    color: var(--text-bright);
    cursor: grab;
    user-select: none;
    font-family: inherit;
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    transition: border-color 0.15s, background 0.15s;
}

.word-tile:hover {
    border-color: var(--accent);
    background: #f0ebe3;
}

.word-tile.used {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

.word-tile.dragging {
    opacity: 0.4;
}

/* Voting screen */
.submissions-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
    text-align: left;
}

.submission-card {
    border: 2px solid var(--line);
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.submission-card.own-submission {
    opacity: 0.5;
    border-style: dashed;
}

.submission-words {
    font-size: clamp(1.1rem, 3vw, 1.5rem);
    color: var(--text-bright);
}

.btn-vote {
    flex-shrink: 0;
}

/* Results screen */
.results-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
    text-align: left;
}

.result-card {
    border: 2px solid var(--line);
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-card .vote-count {
    color: var(--accent);
    font-size: clamp(1.2rem, 3.5vw, 1.8rem);
    font-weight: bold;
}

/* Scoreboard */
#btn-results-invite {
    margin-top: 1rem;
    margin-bottom: 1rem;
}

.scoreboard {
    border: 2px solid var(--line);
    padding: 1.25rem;
}

.scoreboard h3 {
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    letter-spacing: 0.15em;
    color: var(--line-bright);
    margin-bottom: 0.75rem;
}

.score-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    color: var(--text);
    font-size: clamp(1rem, 2.5vw, 1.3rem);
}

.score-row .score-value {
    color: var(--accent);
}

/* Scrollable areas */
.submissions-list,
.results-list {
    max-height: 50vh;
    overflow-y: auto;
}

/* Focus styles */
.pin-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* ── Character Balloon Component ─────────────────────────────── */
.character-balloon {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 0;
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    padding: 0.5rem;
}

.balloon-side {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding-right: 0;
    padding-top: 0.5rem;
    margin-right: -12px;
    z-index: 1;
}

.character-side {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 2;
}

.character-side img {
    height: 320px;
    width: auto;
    opacity: 0.9;
}

.speech-balloon .balloon-text {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.8rem 1rem;
    color: #1a1a1a;
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    line-height: 1.3;
    overflow: hidden;
    word-wrap: break-word;
}

/* Size variants */
.character-balloon.size-sm .character-side img { height: 160px; }
.character-balloon.size-md .character-side img { height: 280px; }
.character-balloon.size-lg .character-side img { height: 420px; }

/* Flipped: character on left, balloon on right */
.character-balloon.flipped {
    flex-direction: row-reverse;
}
.character-balloon.flipped .balloon-side {
    justify-content: flex-start;
    padding-right: 0;
    margin-right: 0;
    margin-left: -12px;
    padding-left: 0;
}

/* Mobile: shrink characters to fit */
@media (max-width: 480px) {
    .character-balloon.size-lg .character-side img { height: 240px; }
    .character-balloon.size-md .character-side img { height: 180px; }
    .character-balloon.size-sm .character-side img { height: 120px; }
}

/* Round winner announcement on results screen */
#round-winner-character {
    margin-bottom: 1rem;
}
