:root {
    --bg: #f7f2e8;
    --bg-soft: #fbf8f1;
    --panel: #fffdf8;
    --text: #3f382f;
    --muted: #8f8375;
    --accent: #6f5e4e;
    --accent-2: #889b72;
    --danger: #b06a5b;
    --border: #e7dccd;
    --shadow: 0 16px 28px rgba(102, 82, 58, 0.12);
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Manrope", "Segoe UI", sans-serif;
    background:
        radial-gradient(900px 500px at 8% -10%, #fffdf6 0%, transparent 62%),
        radial-gradient(700px 420px at 95% 0%, #efe5d4 0%, transparent 62%),
        var(--bg);
    color: var(--text);
    min-height: 100vh;
}
header {
    padding: 34px 24px 18px;
    text-align: center;
}
header h1 {
    margin: 0 0 8px;
    font-family: "Noto Serif JP", serif;
    font-size: clamp(28px, 5vw, 44px);
    letter-spacing: 0.01em;
}
header p {
    margin: 0;
    color: var(--muted);
}
main {
    max-width: 980px;
    margin: 0 auto;
    padding: 0 24px 48px;
    display: grid;
    gap: 20px;
}
.card {
    background: linear-gradient(180deg, #fffdf8, #fbf6ed);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 20px;
}
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}
label {
    font-size: 14px;
    color: #766a5d;
}
select,
input[type="text"] {
    width: 100%;
    margin-top: 6px;
    padding: 11px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    color: var(--text);
}
select:focus,
input[type="text"]:focus {
    outline: none;
    border-color: #c8b59c;
    box-shadow: 0 0 0 3px rgba(111, 94, 78, 0.12);
}
.helper {
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
}
.inline-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 8px;
}
.inline-actions button {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #f4ede1;
    color: var(--text);
    cursor: pointer;
}
.inline-actions button:hover {
    background: #ece2d2;
}
.profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 12px;
}
.avatar-preview {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
}
.avatar-picker {
    position: relative;
    margin-top: 6px;
}
.avatar-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 8px;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fffdf8;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    margin-top: 6px;
    z-index: 10;
    box-shadow: var(--shadow);
    max-height: 200px;
    overflow-y: auto;
}
.avatar-list-item {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    transition: background 0.2s;
}
.avatar-list-item:hover {
    background: #f2e8d9;
}
.avatar-list-item.selected {
    border-color: #c5b196;
    background: #efe2cf;
}
.lang-toggle {
    margin-top: 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
}
.lang-toggle select {
    width: auto;
    margin-top: 0;
}
.winner-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 14px;
    background: #f2f5ea;
    border: 1px solid #dbe4ca;
    color: #5f7450;
    margin-bottom: 12px;
}
.winner-banner.big {
    padding: 18px 20px;
    font-size: 18px;
    box-shadow: 0 14px 22px rgba(96, 118, 80, 0.2);
}
.winner-banner img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.3);
}
.winner-location {
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
}
.match-panel {
    position: fixed;
    right: 20px;
    top: 120px;
    width: 240px;
    display: grid;
    gap: 12px;
    z-index: 999;
}
.match-card {
    background: rgba(255, 252, 245, 0.98);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px;
    box-shadow: var(--shadow);
}
.match-card h3 {
    margin: 0 0 6px;
    font-size: 14px;
    color: var(--muted);
}
.match-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.match-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}
.match-location {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.2;
}
.match-hand {
    font-size: 28px;
    display: block;
}
.match-name {
    font-size: 14px;
    margin-top: 6px;
}
.hand-buttons {
    display: grid;
    gap: 6px;
    margin-top: 6px;
}
.hand-buttons button {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #f4ede1;
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.2s ease;
}
.hand-buttons button:hover {
    transform: translateY(-2px);
    border-color: #bda98f;
}
.status-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}
.pill {
    padding: 6px 10px;
    border-radius: 999px;
    background: #efe5d5;
    color: var(--accent);
    font-size: 13px;
    border: 1px solid #dbcdb7;
}
#map {
    height: 460px;
    width: 100%;
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
}
.legend {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 14px;
    color: var(--muted);
}
.legend-icon {
    width: 12px;
    height: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 6px;
    font-size: 12px;
    line-height: 1;
}
.legend-icon-win {
    border-radius: 50%;
    background: var(--accent-2);
    box-shadow: 0 0 6px rgba(136, 155, 114, 0.45);
}
.legend-icon-lose {
    color: var(--danger);
    text-shadow: 0 0 6px rgba(176, 106, 91, 0.32);
}
.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}
.dot.win { background: var(--accent-2); }
.dot.lose { background: var(--danger); }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.round-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, rgba(255, 250, 241, 0.96), rgba(247, 242, 232, 0.86));
    z-index: 1000;
    text-align: center;
}
.round-overlay.active { display: flex; }
.reentry-popup {
    inset: auto;
    right: 20px;
    bottom: 20px;
    background: transparent;
    align-items: flex-end;
    justify-content: flex-end;
}
.reentry-card {
    max-width: 380px;
    padding: 20px;
    background: #fffdf8;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.round-overlay h2 {
    font-size: clamp(26px, 6vw, 56px);
    margin: 0;
    color: #4d4439;
    font-weight: 700;
    animation: popIn 0.8s ease;
    text-shadow: 0 3px 14px rgba(123, 101, 76, 0.2);
}
.round-overlay p {
    margin: 8px 0 0;
    color: #63584a;
    font-weight: 600;
    text-shadow: 0 2px 10px rgba(122, 100, 74, 0.16);
    animation: fadeIn 1.2s ease;
}
.match-actions {
    display: grid;
    gap: 6px;
    margin-top: 8px;
}
.match-actions button {
    width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #f4ede1;
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
}
@keyframes popIn {
    0% { transform: scale(0.6); opacity: 0; }
    60% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.pulse-self {
    animation: pulseSelf 2.8s ease-out infinite;
}
.pulse-opponent {
    animation: pulseOpp 2.8s ease-out infinite;
}
@keyframes pulseSelf {
    0% { stroke-opacity: 0.9; stroke-width: 1; }
    70% { stroke-opacity: 0; stroke-width: 10; }
    100% { stroke-opacity: 0; stroke-width: 1; }
}
@keyframes pulseOpp {
    0% { stroke-opacity: 0.9; stroke-width: 1; }
    70% { stroke-opacity: 0; stroke-width: 10; }
    100% { stroke-opacity: 0; stroke-width: 1; }
}
.marker-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    border: 1px solid #dfd1bc;
    background: rgba(255, 250, 241, 0.95);
    box-shadow: 0 6px 14px rgba(108, 89, 67, 0.2);
}
.marker-icon-self {
    box-shadow: 0 8px 16px rgba(136, 155, 114, 0.45);
}
.marker-icon-opponent {
    box-shadow: 0 8px 16px rgba(176, 106, 91, 0.42);
}
.marker-cross {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #b06a5b;
    text-shadow: 0 0 10px rgba(176, 106, 91, 0.35);
}
@media (max-width: 820px) {
    .match-panel {
        position: static;
        width: 100%;
        margin: 16px auto 24px;
        padding: 0 24px;
    }
    #map {
        height: 320px;
    }
    .grid {
        grid-template-columns: 1fr;
    }
}
footer {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    padding-bottom: 20px;
}

.btn-primary,
#entry-button {
    width: 100%;
    padding: 13px 16px;
    border-radius: 12px;
    border: 1px solid #7c6a57;
    background: linear-gradient(180deg, #7d6a56, #6f5e4e);
    color: #fffaf1;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    transition: transform 0.16s ease, filter 0.16s ease;
}

.btn-primary:hover,
#entry-button:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
}

.btn-secondary {
    padding: 12px 22px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #f4ede1;
    color: var(--text);
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
}

.btn-secondary:hover {
    background: #ece2d2;
}

.reentry-title {
    margin: 0 0 14px;
    font-family: "Noto Serif JP", serif;
}

.reentry-message {
    margin: 0 0 22px;
    color: var(--muted);
}

.reentry-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}