* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    min-height: 100dvh;
    background: #120c22;
    color: #f6eefe;
    font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    overflow-y: auto;
}

.game-wrap {
    width: 100%;
    max-width: 480px;
    padding: 16px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

a.back {
    color: #d7b4ff;
    text-decoration: none;
    font-size: 14px;
    display: inline-block;
    margin-bottom: 12px;
}

h1 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 12px;
    text-align: center;
    color: #d7b4ff;
}

.top-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(24, 16, 42, .82);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 16px;
    padding: 12px 16px;
    margin-bottom: 12px;
    backdrop-filter: blur(10px);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 12px;
    color: #cbb9e8;
}

.stat-value {
    font-size: 18px;
    font-weight: 600;
    color: #f6eefe;
    margin-top: 2px;
}

.difficulty-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.diff-btn {
    flex: 1;
    background: rgba(24, 16, 42, .82);
    border: 1px solid rgba(255, 255, 255, .12);
    color: #cbb9e8;
    padding: 10px;
    border-radius: 12px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.diff-btn.active {
    background: #d7b4ff;
    color: #120c22;
    border-color: #d7b4ff;
    font-weight: 600;
}

.grid-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 12px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.entry-exit {
    position: relative;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    margin: 4px 0;
}

#entryIcon,
#exitIcon {
    justify-self: center;
    align-self: center;
    line-height: 1;
    filter: drop-shadow(0 0 4px rgba(215, 180, 255, 0.6));
}

.grid {
    display: grid;
    gap: 2px;
    background: rgba(255, 255, 255, .05);
    padding: 2px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .12);
}

.cell {
    background: rgba(24, 16, 42, .6);
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    aspect-ratio: 1;
}

.cell:active {
    transform: scale(0.95);
}

.cell svg {
    width: 100%;
    height: 100%;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cell.filled svg path,
.cell.filled svg circle {
    stroke: #4ade80 !important;
    filter: drop-shadow(0 0 6px #4ade80);
    transition: stroke 0.35s ease, filter 0.35s ease;
}

.cell.hint svg path,
.cell.hint svg circle {
    stroke: #4ade80 !important;
    filter: drop-shadow(0 0 8px #4ade80);
}

.cell.activated-tee {
    box-shadow: inset 0 0 0 3px #fbbf24;
    position: relative;
}

.cell.activated-tee::after {
    content: "T";
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 10px;
    font-weight: 700;
    color: #fbbf24;
    pointer-events: none;
}

.cell.exit {
    box-shadow: inset 0 -3px 0 #d7b4ff;
}

.bottom-panel {
    display: flex;
    gap: 12px;
    position: sticky;
    bottom: 8px;
    z-index: 10;
    background: linear-gradient(to top, #120c22 70%, transparent);
    padding-top: 12px;
    margin-top: 8px;
}

.btn {
    flex: 1;
    background: rgba(24, 16, 42, .82);
    border: 1px solid rgba(255, 255, 255, .12);
    color: #f6eefe;
    padding: 14px;
    border-radius: 16px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    backdrop-filter: blur(10px);
}

.btn:active {
    transform: scale(0.96);
}

.btn-accent {
    background: #d7b4ff;
    color: #120c22;
    border-color: #d7b4ff;
    font-weight: 600;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(18, 12, 34, 0.9);
    backdrop-filter: blur(10px);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: rgba(24, 16, 42, .95);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 20px;
    padding: 24px;
    max-width: 320px;
    width: 100%;
    text-align: center;
}

.modal-title {
    font-size: 22px;
    font-weight: 600;
    color: #d7b4ff;
    margin-bottom: 16px;
}

.modal-stats {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
    padding: 16px;
    background: rgba(255, 255, 255, .05);
    border-radius: 12px;
}

.modal-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal-stat-label {
    font-size: 12px;
    color: #cbb9e8;
}

.modal-stat-value {
    font-size: 20px;
    font-weight: 600;
    color: #f6eefe;
}

.modal-btn {
    width: 100%;
    background: #d7b4ff;
    color: #120c22;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

.modal-btn-secondary {
    background: rgba(255, 255, 255, .1);
    color: #f6eefe;
    margin-top: 8px;
}

.records {
    background: rgba(24, 16, 42, .82);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 16px;
    padding: 12px;
    margin-bottom: 12px;
    font-size: 12px;
    color: #cbb9e8;
    position: relative;
}

.records-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    color: #d7b4ff;
    margin-bottom: 8px;
}

.records-close {
    background: none;
    border: none;
    color: #cbb9e8;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.records-close:hover,
.records-close:active {
    opacity: 1;
    color: #f6eefe;
}

.records-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.record-item {
    display: flex;
    justify-content: space-between;
}

.icon-btn {
    cursor: pointer;
    font-size: xx-large;
}