:root {
    --bg: #FFF7EE;
    --ink: #241A17;
    --text-secondary: #5A4A42;
    --text-muted: #8C7E77;
    --chip-bg: #FFF1E0;
    --coral: #FF5A4D;
    --yellow: #FFC93C;
    --teal: #2FBF9A;
    --purple: #7C5CFF;
    --pink: #FF7DAE;
    --font-display: 'Mitr', sans-serif;
    --font-body: 'IBM Plex Sans Thai', sans-serif;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
}

.page {
    max-width: 480px;
    margin: 0 auto;
    padding: 20px 16px 60px;
}

h1 {
    font-family: var(--font-display);
    font-weight: 700;
    text-align: center;
    margin-bottom: 4px;
    color: var(--coral);
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 0;
    margin-bottom: 24px;
    font-size: 14px;
}

.back-home {
    display: inline-block;
    margin-bottom: 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
}

.back-home:hover {
    color: var(--coral);
}

.entry-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.entry-tab {
    flex: 1;
    background: #fff;
    color: var(--ink);
    box-shadow: 2px 2px 0 var(--ink);
    font-size: 15px;
    padding: 12px 10px;
}

.entry-tab.active {
    background: var(--ink);
    color: var(--bg);
    box-shadow: 3px 3px 0 var(--coral);
}

.entry-panel {
    display: none;
}

.entry-panel.active {
    display: block;
}

.card {
    background: #fff;
    border: 2px solid var(--ink);
    border-radius: 20px;
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: 5px 5px 0 var(--ink);
}

.card h2 {
    font-family: var(--font-display);
    font-weight: 600;
    margin-top: 0;
    font-size: 18px;
}

form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

input, select {
    padding: 12px;
    border-radius: 10px;
    border: 1.5px solid #C9BDB6;
    background: #fff;
    color: var(--ink);
    font-size: 16px;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--coral);
}

button {
    padding: 12px;
    border-radius: 999px;
    border: 2px solid var(--ink);
    background: var(--coral);
    color: #fff;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 3px 3px 0 var(--ink);
    transition: transform .12s, box-shadow .12s;
}

button:hover {
    transform: translate(1px, 1px);
    box-shadow: 2px 2px 0 var(--ink);
}

button:disabled {
    background: #E5DED8;
    color: var(--text-muted);
    border-color: #C9BDB6;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

button.secondary {
    background: #fff;
    color: var(--ink);
}

.error {
    color: #D1373A;
    text-align: center;
    min-height: 20px;
    font-size: 14px;
}

a {
    color: var(--coral);
}

.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.room-code-label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
}

.room-code {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--coral);
}

.player-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.player-list li {
    display: flex;
    justify-content: space-between;
    padding: 8px 4px;
    border-bottom: 1px solid #EEE6DE;
}

.player-list li.me {
    color: var(--coral);
    font-weight: 700;
}

.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #C9BDB6;
    margin-right: 6px;
}

.dot.online {
    background: var(--teal);
}

.role-card {
    text-align: center;
    padding: 24px 16px;
}

.role-card .role-name {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    color: var(--coral);
    margin: 8px 0;
}

.role-card .role-desc {
    color: var(--text-secondary);
}

.behavior-tag {
    display: inline-block;
    margin-top: 12px;
    padding: 6px 16px;
    border-radius: 999px;
    background: var(--chip-bg);
    border: 1.5px solid var(--ink);
    font-size: 14px;
    font-weight: 500;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--chip-bg);
    border: 1.5px solid var(--ink);
    color: var(--ink);
}

.badge.police { background: var(--purple); color: #fff; }
.badge.host { background: var(--yellow); color: var(--ink); }

.badge.faction-police { background: var(--purple); color: #fff; }
.badge.faction-owner { background: var(--coral); color: #fff; }
.badge.faction-indep { background: var(--teal); color: #fff; }

.investigation-item {
    background: var(--chip-bg);
    border: 1.5px solid var(--ink);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 8px;
}

.accuse-list button, .vote-list button {
    text-align: left;
    background: #fff;
    color: var(--ink);
    border: 2px solid var(--ink);
    margin-bottom: 8px;
    width: 100%;
    box-shadow: 3px 3px 0 var(--ink);
}

.accuse-list button.selected, .vote-list button.selected {
    background: var(--coral);
    color: #fff;
}

.result-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #EEE6DE;
}

.result-row .score-delta.positive { color: var(--teal); font-weight: 700; }
.result-row .score-delta.negative { color: #D1373A; font-weight: 700; }

.center-text { text-align: center; }
.muted { color: var(--text-muted); font-size: 14px; }

.howto-steps {
    margin: 0;
    padding-left: 20px;
}

.howto-steps li {
    margin-bottom: 10px;
    line-height: 1.5;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.game-card {
    position: relative;
    border-radius: 14px;
    padding: 14px 10px;
    text-align: center;
    border: 2px solid var(--ink);
}

.game-card-count {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 11px;
    font-weight: 700;
    background: var(--ink);
    color: var(--bg);
    padding: 2px 8px;
    border-radius: 999px;
}

.game-card-icon {
    font-size: 32px;
    line-height: 1;
    margin-bottom: 8px;
}

.game-card-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.game-card-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.game-card.character { background: #FFF3CC; }
.game-card.behavior { background: #EDE6FF; }
.game-card.case { background: #FFE1DD; }
.game-card.investigation { background: #DFF6EE; }

.setup-field {
    margin-bottom: 14px;
}

.setup-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
}

.radio-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    margin-bottom: 0;
}

.radio-group input[type="radio"] {
    width: auto;
}

.stepper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stepper-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    line-height: 1;
    font-size: 18px;
    border-radius: 10px;
    box-shadow: 2px 2px 0 var(--ink);
}

.stepper-value {
    min-width: 20px;
    text-align: center;
    font-weight: 700;
}
