:root {
    color-scheme: light;
    --teto-bg: #fdf6f8;
    --teto-ink: #201923;
    --teto-muted: #6f6472;
    --teto-line: #eadde5;
    --teto-panel: rgba(255, 255, 255, 0.96);
    --teto-pink: #f657b5;
    --teto-blue: #2878f0;
    --teto-green: #14a86a;
    --teto-gold: #ffb82e;
    --teto-deep: #d8648e;
    --game-header-side-bg: var(--teto-bg);
    --game-header-center-bg: #fff;
    --game-header-accent: var(--teto-pink);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    touch-action: manipulation;
}

body {
    color: var(--teto-ink);
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
    letter-spacing: 0;
    -webkit-text-size-adjust: 100%;
    background:
        linear-gradient(
            to right,
            var(--teto-bg) 0,
            var(--teto-bg) calc((100% - 450px) / 2),
            #fff calc((100% - 450px) / 2),
            #fff calc((100% + 450px) / 2),
            var(--teto-bg) calc((100% + 450px) / 2),
            var(--teto-bg) 100%
        );
}

button,
a {
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

.teto-shell {
    display: grid;
    place-items: start center;
    min-height: 100vh;
    padding: 8px 10px max(14px, env(safe-area-inset-bottom));
}

.teto-stage {
    width: min(100%, 430px);
    padding-bottom: 14px;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.control-pad button,
.overlay-panel button,
.side-action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border: 0;
    border-radius: 8px;
    color: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 900;
    text-decoration: none;
    background: var(--teto-pink);
    box-shadow: 0 7px 16px rgba(216, 100, 142, 0.18);
    cursor: pointer;
}

.teto-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 104px;
    gap: 10px;
    align-items: start;
    padding: 10px;
    border-radius: 8px;
    background:
        radial-gradient(circle at 18% 0, rgba(246, 87, 181, 0.2), transparent 30%),
        radial-gradient(circle at 86% 12%, rgba(40, 120, 240, 0.2), transparent 32%),
        linear-gradient(180deg, rgba(21, 24, 84, 0.96), rgba(9, 13, 55, 0.96));
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.14),
        inset 0 0 32px rgba(61, 176, 255, 0.1),
        0 14px 32px rgba(26, 25, 80, 0.26);
}

.teto-board-wrap {
    position: relative;
    min-width: 0;
    padding: 0;
    border-radius: 8px;
    background: transparent;
    box-shadow: none;
}

.teto-canvas {
    display: block;
    width: 100%;
    aspect-ratio: 0.5555556;
    border-radius: 8px;
    background: #11164e;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.teto-side {
    display: grid;
    gap: 8px;
}

.score-grid {
    display: grid;
    gap: 6px;
}

.score-grid > div,
.next-panel {
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(41, 55, 148, 0.82), rgba(16, 21, 85, 0.82)),
        rgba(18, 22, 88, 0.74);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.18),
        inset 0 -6px 12px rgba(0, 0, 0, 0.18),
        0 10px 24px rgba(6, 10, 48, 0.16);
    backdrop-filter: blur(14px) saturate(1.08);
    -webkit-backdrop-filter: blur(14px) saturate(1.08);
}

.score-grid > div {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    min-height: 42px;
    padding: 7px 8px;
}

.teto-stat-icon,
.next-panel span {
    display: block;
    color: rgba(255, 255, 255, 0.68);
    font-size: 17px;
    font-weight: 900;
    line-height: 1;
}

.next-panel span {
    font-size: 10px;
    line-height: normal;
}

.teto-stat-icon {
    flex: 0 0 auto;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.42);
}

.score-grid strong {
    display: block;
    min-width: 0;
    color: #fff;
    font-size: 18px;
    line-height: 1.1;
    white-space: nowrap;
    text-shadow:
        0 1px 0 rgba(0, 0, 0, 0.46),
        0 0 10px rgba(246, 87, 181, 0.28);
}

.next-panel {
    padding: 8px;
}

.next-panel canvas {
    display: block;
    width: 100%;
    height: auto;
    margin-top: 4px;
    border-radius: 8px;
    background: #171b5c;
}

.control-pad {
    display: grid;
    grid-template-columns: repeat(3, 28px);
    grid-template-areas:
        ". rotate ."
        "left . right"
        ". drop .";
    justify-content: center;
    gap: 4px;
    margin-top: 0;
    padding: 4px 3px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    background: rgba(12, 16, 66, 0.52);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        inset 0 -8px 16px rgba(0, 0, 0, 0.12);
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.control-pad button {
    position: relative;
    width: 28px;
    min-height: 28px;
    height: 28px;
    padding: 0;
    overflow: hidden;
    font-size: 18px;
    line-height: 1;
    background:
        radial-gradient(circle at 34% 18%, rgba(255, 255, 255, 0.5), transparent 20%),
        linear-gradient(180deg, #3e8cff, var(--teto-blue));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.42),
        inset 0 -8px 14px rgba(16, 67, 156, 0.2),
        0 8px 16px rgba(40, 120, 240, 0.14);
    text-shadow: 0 2px 0 rgba(18, 45, 112, 0.2);
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

#leftButton {
    grid-area: left;
}

#rotateButton {
    grid-area: rotate;
}

#rightButton {
    grid-area: right;
}

#dropButton {
    grid-area: drop;
}

.control-pad button:nth-child(2) {
    background:
        radial-gradient(circle at 34% 18%, rgba(255, 255, 255, 0.54), transparent 20%),
        linear-gradient(180deg, #ffc94d, var(--teto-gold));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.46),
        inset 0 -8px 14px rgba(176, 116, 13, 0.2),
        0 8px 16px rgba(255, 184, 46, 0.14);
    text-shadow: 0 2px 0 rgba(126, 81, 6, 0.2);
}

.control-pad button:nth-child(4) {
    font-size: 22px;
    background:
        radial-gradient(circle at 34% 18%, rgba(255, 255, 255, 0.5), transparent 20%),
        linear-gradient(180deg, #25c782, var(--teto-green));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.42),
        inset 0 -8px 14px rgba(8, 102, 65, 0.22),
        0 8px 16px rgba(20, 168, 106, 0.14);
    text-shadow: 0 2px 0 rgba(7, 85, 53, 0.22);
}

.control-pad button::after {
    content: "";
    position: absolute;
    inset: 2px 2px auto;
    height: 32%;
    border-radius: 7px 7px 50% 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.32), transparent);
    pointer-events: none;
}

.control-pad button:active {
    transform: translateY(1px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.34),
        inset 0 -5px 10px rgba(16, 67, 156, 0.18),
        0 4px 10px rgba(40, 120, 240, 0.1);
}

.teto-overlay {
    position: absolute;
    inset: 8px;
    z-index: 4;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: rgba(12, 15, 55, 0.68);
    backdrop-filter: blur(7px);
}

.teto-overlay[hidden] {
    display: none;
}

.overlay-panel {
    width: min(90%, 300px);
    padding: 22px 18px 18px;
    border-radius: 8px;
    text-align: center;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 18px 36px rgba(10, 11, 45, 0.28);
}

.result-panel {
    width: min(92%, 312px);
    padding: 24px 18px 18px;
    border: 1px solid rgba(32, 25, 35, 0.08);
    color: var(--teto-ink);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(251, 250, 253, 0.98));
    box-shadow:
        0 24px 52px rgba(9, 12, 44, 0.24),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.result-panel::before {
    content: "";
    display: block;
    width: 40px;
    height: 3px;
    margin: 0 auto 16px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--teto-pink), var(--teto-blue));
}

.start-panel {
    position: relative;
    overflow: hidden;
    padding: 24px 18px 20px;
    color: #fff;
    background:
        radial-gradient(circle at 22% 12%, rgba(246, 87, 181, 0.34), transparent 30%),
        radial-gradient(circle at 78% 18%, rgba(40, 120, 240, 0.32), transparent 32%),
        linear-gradient(180deg, rgba(18, 22, 88, 0.98), rgba(9, 13, 55, 0.98));
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.18),
        inset 0 -16px 28px rgba(0, 0, 0, 0.2),
        0 20px 38px rgba(10, 11, 45, 0.34);
}

.start-panel::before {
    content: "";
    position: absolute;
    inset: 7px;
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 7px;
    pointer-events: none;
}

.start-hero {
    width: 92px;
    margin: 2px auto 14px;
}

.start-hero img {
    display: block;
    width: 64px;
    height: 64px;
    margin: 0 auto;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.9);
    box-shadow:
        0 0 0 5px rgba(246, 87, 181, 0.18),
        0 12px 22px rgba(0, 0, 0, 0.24);
}

.start-blocks {
    display: grid;
    grid-template-columns: repeat(4, 16px);
    justify-content: center;
    gap: 5px;
    margin-top: 7px;
}

.start-blocks i {
    display: block;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.38), transparent 42%),
        var(--block-color, var(--teto-pink));
    box-shadow:
        inset 0 -3px 5px rgba(0, 0, 0, 0.16),
        0 0 14px color-mix(in srgb, var(--block-color, var(--teto-pink)) 48%, transparent);
}

.start-blocks i:nth-child(2) {
    --block-color: var(--teto-blue);
}

.start-blocks i:nth-child(3) {
    --block-color: var(--teto-gold);
}

.start-blocks i:nth-child(4) {
    --block-color: var(--teto-green);
}

.start-panel strong {
    color: #fff;
    font-size: 32px;
    letter-spacing: 0;
    text-shadow:
        0 2px 0 rgba(0, 0, 0, 0.18),
        0 0 18px rgba(246, 87, 181, 0.38);
}

.start-panel button {
    min-width: 106px;
    min-height: 44px;
    margin-top: 18px;
    border-radius: 8px;
    font-size: 14px;
    letter-spacing: 0.08em;
    background:
        radial-gradient(circle at 36% 18%, rgba(255, 255, 255, 0.42), transparent 20%),
        linear-gradient(180deg, #ff72cb, var(--teto-pink));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.38),
        inset 0 -8px 14px rgba(146, 26, 98, 0.24),
        0 10px 24px rgba(246, 87, 181, 0.32);
}

.overlay-panel span {
    display: block;
    color: var(--teto-pink);
    font-size: 11px;
    font-weight: 900;
}

.result-panel span {
    color: var(--teto-muted);
    font-size: 10px;
    letter-spacing: 0.12em;
}

.overlay-panel strong {
    display: block;
    margin-top: 4px;
    color: var(--teto-deep);
    font-size: 24px;
    line-height: 1.18;
}

.result-panel strong {
    margin-top: 5px;
    color: var(--teto-ink);
    font-size: 28px;
    line-height: 1.15;
}

.overlay-panel p {
    margin: 10px 0 16px;
    color: var(--teto-muted);
    font-size: 13px;
    line-height: 1.65;
}

.result-panel p {
    margin: 12px 0 17px;
    color: var(--teto-muted);
    font-size: 15px;
    font-weight: 800;
    line-height: 1.5;
}

.result-stats,
.global-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin: 12px 0 14px;
}

.result-panel .result-stats {
    gap: 8px;
    margin: 0 0 18px;
}

.result-stats div,
.global-grid div {
    min-width: 0;
    padding: 8px 7px;
    border-radius: 8px;
    background: rgba(34, 32, 111, 0.07);
}

.result-panel .result-stats div {
    min-height: 68px;
    padding: 10px 8px;
    border: 1px solid rgba(32, 25, 35, 0.06);
    background: #f3f2f7;
}

.result-stats dt,
.global-grid dt {
    color: var(--teto-muted);
    font-size: 10px;
    font-weight: 900;
}

.result-panel .result-stats dt {
    color: #746d78;
    font-size: 11px;
}

.result-stats dd,
.global-grid dd {
    margin: 3px 0 0;
    color: var(--teto-deep);
    font-size: 13px;
    font-weight: 900;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.result-panel .result-stats dd {
    margin-top: 6px;
    color: var(--teto-deep);
    font-size: 17px;
}

.result-panel button {
    width: min(100%, 180px);
    min-height: 46px;
    border-radius: 8px;
    color: #fff;
    font-size: 15px;
    letter-spacing: 0;
    background:
        linear-gradient(180deg, #ff70c8, var(--teto-pink));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.36),
        0 12px 24px rgba(246, 87, 181, 0.22);
}

.side-action-button {
    width: 100%;
    min-height: 36px;
}

.global-panel {
    margin-top: 10px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.66);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.58);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        0 10px 24px rgba(216, 100, 142, 0.07);
    backdrop-filter: blur(14px) saturate(1.08);
    -webkit-backdrop-filter: blur(14px) saturate(1.08);
}

.global-panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.global-panel-head span {
    color: var(--teto-ink);
    font-size: 14px;
    font-weight: 900;
}

.global-panel-head small {
    min-width: 0;
    color: var(--teto-muted);
    font-size: 10px;
    font-weight: 800;
    text-align: right;
}

.global-grid {
    margin: 8px 0 0;
}

@media (max-width: 370px) {
    .teto-layout {
        grid-template-columns: minmax(0, 1fr) 88px;
        gap: 7px;
    }

    .control-pad {
        grid-template-columns: repeat(3, 24px);
    }

    .control-pad button {
        width: 24px;
        min-height: 24px;
        height: 24px;
        font-size: 16px;
    }

    .control-pad button:nth-child(4) {
        font-size: 18px;
    }

    .score-grid > div {
        min-height: 40px;
        gap: 4px;
        padding: 6px 7px;
    }

    .score-grid strong {
        font-size: 16px;
    }
}
