:root {
    font-family: "Noto Sans JP", "Inter", "Helvetica Neue", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --bg: #f5f5f7;
    --surface: #ffffff;
    --text: #101828;
    --muted: #5f6b7c;
    --line: #e4e6eb;
    --accent: #2563eb;
    --accent-muted: #dbeafe;
    --success: #16a34a;
    --warning: #dc2626;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    padding: 0.6rem;
}

.app-shell {
    max-width: 420px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.top-bar {
    background: var(--surface);
    border-radius: 0.9rem;
    padding: 0.4rem 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    border: 1px solid var(--line);
}

.top-bar .badge {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
}

.top-bar h1 {
    flex: 1;
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.scenario-brief {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    background: var(--accent-muted);
    border-radius: 0.9rem;
    border: 1px solid var(--line);
    padding: 0.45rem 0.6rem;
}

.player-badge {
    flex: 0 0 auto;
    padding: 0.2rem 0.5rem;
    border-radius: 0.6rem;
    background: #0f172a;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
}

.scenario-summary {
    margin: 0;
    font-size: 0.82rem;
    color: #0f172a;
    line-height: 1.4;
}

.cards-panel,
.action-panel,
.feedback-panel {
    background: var(--surface);
    border-radius: 0.9rem;
    border: 1px solid var(--line);
    padding: 0.75rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
}

.panel-header .label {
    margin: 0;
    font-weight: 600;
}

.hand-grid {
    display: flex;
    justify-content: space-between;
    gap: 0.35rem;
}

.card {
    position: relative;
    flex: 1;
    aspect-ratio: 64 / 90;
    border-radius: 0.65rem;
    background: linear-gradient(180deg, #ffffff, #f1f1f3);
    border: 1.6px solid #d4d4d8;
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.18), inset 0 -4px 8px rgba(0, 0, 0, 0.08);
    padding: 0.45rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    overflow: hidden;
}

.card::before {
    content: "";
    position: absolute;
    inset: 0.2rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.6);
    pointer-events: none;
}

.card .corner {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-weight: 700;
    line-height: 1.1;
    font-size: 0.95rem;
}

.card .corner.top {
    top: 0.3rem;
    left: 0.3rem;
}

.card .corner.bottom {
    bottom: 0.3rem;
    right: 0.3rem;
    transform: rotate(180deg);
}

.card .pip {
    font-size: 2.5rem;
    line-height: 1;
}

.card .suit {
    font-size: 0.9rem;
}

.card.red {
    color: #d22f27;
}

.card.black {
    color: #111827;
}

.card.selected {
    border-color: var(--accent);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22), inset 0 -4px 8px rgba(37, 99, 235, 0.18);
    transform: translateY(-4px);
}

.hint {
    margin: 0.35rem 0 0;
    font-size: 0.76rem;
    color: var(--muted);
    text-align: center;
}

.option-row {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.option {
    padding: 0.6rem;
    border-radius: 0.6rem;
    border: 1px solid var(--line);
    background: #f8fafc;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: border 0.15s ease, background 0.15s ease;
    flex: 1;
    text-align: center;
}

.option.active {
    border-color: var(--accent);
    background: var(--accent-muted);
    color: var(--accent);
}

.primary-btn,
.refresh-btn {
    border: none;
    border-radius: 0.7rem;
    padding: 0.65rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

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

.secondary-btn {
    background: #e2e8f0;
    color: #0f172a;
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 0.7rem;
}

.secondary-btn.colored {
    background: rgba(37, 99, 235, 0.12);
    color: var(--accent);
    border-color: rgba(37, 99, 235, 0.3);
}

.refresh-btn {
    background: #0f172a;
    color: #fff;
    width: 100%;
    margin-top: 0.2rem;
}

.action-cta {
    width: 100%;
    margin-top: 0.3rem;
}

button:disabled {
    opacity: 0.4;
}

button:active {
    transform: scale(0.98);
}

.feedback-panel {
    display: grid;
    gap: 0.45rem;
}

.appeal-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 0.9rem;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.appeal-panel h3 {
    margin: 0;
    font-size: 0.95rem;
}

.appeal-panel textarea {
    width: 100%;
    border-radius: 0.7rem;
    border: 1px solid var(--line);
    padding: 0.6rem;
    resize: vertical;
    font-family: inherit;
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
}

.appeal-status {
    margin: 0;
    font-size: 0.8rem;
    color: var(--muted);
    min-height: 1rem;
}

.result-card {
    border: 1px solid var(--line);
    border-radius: 0.7rem;
    padding: 0.6rem;
    background: #fdfdfd;
}

.result-card .label {
    margin: 0;
    font-size: 0.76rem;
    color: var(--muted);
}

.result-text {
    margin: 0.1rem 0 0;
    font-weight: 600;
}

.result-text.success {
    color: var(--success);
}

.result-text.error {
    color: var(--warning);
}

.note-card .note {
    margin: 0.15rem 0 0;
}

.footer-note {
    text-align: center;
    font-size: 0.7rem;
    color: var(--muted);
    margin: 0.3rem 0 0.8rem;
}

@media (max-width: 400px) {
    body {
        padding: 0.5rem;
    }

    .hand-grid {
        gap: 0.25rem;
    }
}
