.kokon-game-dialog {
    box-sizing: border-box;
    width: min(580px, calc(100vw - 28px));
    max-height: calc(100dvh - 24px);
    margin: auto;
    padding: clamp(16px, 4vw, 28px);
    border: 3px solid #e8af4d;
    border-radius: 22px;
    background: radial-gradient(ellipse at 50% 0, #12646d, #092d3a 74%);
    color: #ffebbb;
    box-shadow: inset 0 0 0 4px #082830, 0 18px 56px #0009;
    text-align: center;
    font: 16px Georgia, serif;
    overflow: auto;
}
.kokon-game-dialog::backdrop { background: #041b23bd; }
.kokon-game-dialog h1 { margin: 0; padding-inline: 42px; font-size: clamp(23px, 6vw, 36px); }
.kokon-hero-picker p { margin: 9px 0 17px; color: #bfe4dc; font: 15px system-ui, sans-serif; }
.kokon-about-text {
    max-height: max(80px, calc(100dvh - 160px));
    overflow: auto;
    margin: 16px 0 0;
    color: #e9f4ed;
    font: 16px/1.55 system-ui, sans-serif;
    white-space: pre-line;
}
.kokon-hero-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kokon-game-dialog button {
    font: bold clamp(14px, 3.6vw, 18px) Georgia, serif;
    color: inherit;
    border: 1px solid #a57c42;
    border-radius: 13px;
    background: #154650;
    cursor: pointer;
}
.kokon-game-dialog .kokon-picker-close {
    position: absolute;
    top: 12px;
    right: 12px;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 8px;
    background: #0b3440;
    font: 25px/1 system-ui, sans-serif;
}
.kokon-hero-options button { padding: 9px 5px 12px; }
.kokon-hero-options button[aria-pressed="true"] {
    border-color: #ffda77;
    background: radial-gradient(ellipse, #217b7a, #154650 75%);
    box-shadow: inset 0 0 0 1px #e6ad49;
}
.kokon-game-dialog button:focus-visible { outline: 3px solid #fff2b2; outline-offset: 3px; }
.kokon-hero-options img {
    display: block;
    height: clamp(72px, 24vh, 155px);
    width: 100%;
    object-fit: contain;
    margin: 0 auto 7px;
}
.kokon-picker-actions { display: flex; justify-content: center; margin-top: 17px; }
.kokon-picker-actions button { min-height: 45px; }
.kokon-picker-actions [data-action="play"] {
    width: min(304px, 100%);
    color: #17383b;
    background: linear-gradient(#ffe7a4, #e9af42);
    border-color: #ffe3a0;
}
.kokon-name-form {
    display: grid;
    gap: 10px;
    width: min(100%, 400px);
    margin: 20px auto 0;
    text-align: left;
    font: 16px/1.4 system-ui, sans-serif;
}
.kokon-name-form input {
    box-sizing: border-box;
    width: 100%;
    min-height: 48px;
    padding: 10px 14px;
    border: 1px solid #a57c42;
    border-radius: 10px;
    background: #0b3440;
    color: #ffebbb;
    font: inherit;
}
.kokon-name-form input:focus-visible {
    outline: 2px solid #ffda77;
    outline-offset: 2px;
}
.kokon-name-form [aria-invalid="true"] { border-color: #ff9c88; }
.kokon-name-form [role="status"] { margin: 0; color: #ffc3a8; }
.kokon-name-form [role="status"]:empty { display: none; }
.kokon-game-dialog button:disabled { opacity: .65; cursor: wait; }
.kokon-certificate-dialog {
    width: min(760px, calc(100vw - 24px));
    height: min(820px, calc(100dvh - 24px));
    overflow: hidden;
    padding: 0;
}
.kokon-certificate-dialog[open] {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}
.kokon-certificate-dialog header {
    position: relative;
    min-height: 56px;
    box-sizing: border-box;
    padding: 14px 56px;
    border-bottom: 1px solid #a57c42;
}
.kokon-certificate-dialog h2 { margin: 0; font-size: clamp(21px, 4vw, 27px); }
.kokon-certificate-dialog .kokon-picker-close { top: 8px; right: 12px; }
.kokon-certificate-dialog iframe {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 0;
    background: #092d3a;
    touch-action: pan-y;
}
@media (max-height: 420px) {
    .kokon-game-dialog:not(.kokon-certificate-dialog) { padding: 12px; }
    .kokon-hero-picker p { margin: 4px 0 8px; }
    .kokon-hero-options img { height: min(22vh, 100px); }
    .kokon-picker-actions { margin-top: 9px; }
}

html:has(.kokon-ranking), body:has(.kokon-ranking) {
    touch-action: pan-y;
}
.kokon-ranking {
    box-sizing: border-box;
    position: fixed;
    inset: 12px 0 auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
    width: min(760px, calc(100vw - 24px));
    height: min(780px, calc(100dvh - 24px));
    margin: 0 auto;
    overflow: hidden;
    border: 1px solid #d5b477;
    border-radius: 18px;
    background: #0b3440;
    color: #ffebbb;
    box-shadow: 0 14px 44px #0009;
    font-family: system-ui, sans-serif;
}
.kokon-ranking #top-bar {
    flex: none;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #104652;
    border-bottom: 1px solid #a78650;
}
.kokon-ranking h2 {
    grid-column: 2;
    margin: 0;
    text-align: center;
    font: bold 23px Georgia, serif;
}
.kokon-ranking #closeModal {
    grid-column: 3;
    width: 38px;
    height: 38px;
    border: 1px solid #d5b477;
    border-radius: 8px;
    background: #0b3440;
    color: #ffebbb;
    font: 25px/1 system-ui, sans-serif;
    cursor: pointer;
}
.kokon-ranking button:focus-visible, .kokon-ranking .ranking-list:focus-visible {
    outline: 2px solid #ffe38f;
    outline-offset: -3px;
}
.kokon-ranking .ranking-list {
    flex: 1 1 0;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-color: #a78650 #0b3440;
    padding: 14px;
    touch-action: pan-y;
}
.kokon-ranking .ranking-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px 8px 12px;
    border: 1px solid #4b7777;
    border-radius: 10px;
    background: #164b55;
    color: #ffebbb;
    font-size: 14px;
    overflow-wrap: anywhere;
}
.kokon-ranking .ranking-row + .ranking-row { margin-top: 10px; }
.kokon-ranking form { flex: none; margin: 0; }
.kokon-ranking .ranking-btn {
    min-height: 34px;
    padding: 5px 10px;
    border: 0;
    border-radius: 7px;
    background: #e8bb62;
    color: #113641;
    cursor: pointer;
}
.kokon-ranking .ranking-message { margin: 16px 0; text-align: center; }
