* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body, #app, .screen, .container, .content, .footer, button, .number, .operation, .score, .target, .result, .header, * {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f3f4f6;
    background-image: radial-gradient(circle, #b0b0b0 0.5px, transparent 1px);
    background-size: 20px 20px;
    background-repeat: repeat;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    width: 100%;
    max-width: 500px;
    min-width: 320px;
}

.screen {
    background-color: white;
    box-shadow: 0 20px 60px -15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.hidden {
    display: none !important;
}

.container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.header {
    background-color: #16a34a;
    padding: 1rem;
    text-align: center;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.score-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.score-label {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.score {
    background-color: #16a34a;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-weight: 700;
    border: 2px solid white;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.header p {
    font-size: 1rem;
    font-weight: 500;
    opacity: 0.9;
}

.content {
    flex: 1;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.75rem;
}

.footer {
    display: flex;
    justify-content: center;
    padding: 1rem;
    text-align: center;
    background-color: #16a34a;
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.button {
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 700;
    font-size: 1rem;
    border: 2px solid;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    letter-spacing: 0.02em;
}

.button.primary {
    background-color: #22c55e;
    color: white;
    border-color: #166534;
    box-shadow: 0 6px 0 #166534;
}

.button.primary:hover {
    background-color: #16a34a;
    transform: translateY(2px);
    box-shadow: 0 3px 0 #166534;
}

.button.secondary {
    background-color: #f97316;
    color: white;
    border-color: #c2410c;
    box-shadow: 0 6px 0 #c2410c;
}

.button.secondary:hover {
    background-color: #ea580c;
    transform: translateY(2px);
    box-shadow: 0 3px 0 #c2410c;
}

.button.icon {
    width: 3rem;
    height: 3rem;
    margin: 0;
    padding: 0;
    background-color: white;
    color: #16a34a;
    border-color: #16a34a;
    box-shadow: 0 3px 0 #166534;
}

.button.icon:hover {
    background-color: #f0fdf4;
    transform: translateY(1px);
    box-shadow: 0 1px 0 #166534;
}

.button span {
    display: block;
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0;
}

.target {
    background-color: #f0fdf4;
    padding: 1rem;
    border-radius: 0.75rem;
    border: 2px solid #dcfce7;
}

.target-label {
    text-align: center;
    margin-bottom: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.target-result {
    text-align: center;
    font-size: 1.25rem;
    font-weight: 800;
    background-color: white;
    padding: 0.5rem;
    border-radius: 0.5rem;
    border: 2px solid #86efac;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    letter-spacing: -0.02em;
}

.game-board {
    background-color: #f0fdf4;
    padding: 1rem;
    border-radius: 0.75rem;
    border: 2px solid #dcfce7;
    flex: 1;
    position: relative;
}

.numbers-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.number {
    width: 100%;
    max-width: 80px;
    flex: 1;
    min-width: 0;
}

.number-display {
    width: 100%;
    min-width: 0;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.operation {
    position: relative;
    margin: 0 0.25rem;
    width: 100%;
    max-width: 40px;
    flex: 1;
    min-width: 0;
}

.operation-display {
    width: 100%;
    min-width: 0;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    font-weight: 700;
    border-radius: 0.5rem;
    letter-spacing: -0.02em;
}

.operation-options {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    border-radius: 0.5rem;
    z-index: 1;
}

.operation-option {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 0.5rem;
    border: 2px solid;
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: -0.02em;
}

.operation-option.plus {
    background-color: #22c55e;
    color: white;
    border-color: #166534;
    box-shadow: 0 2px 0 #166534;
}

.operation-option.minus {
    background-color: #f97316;
    color: white;
    border-color: #c2410c;
    box-shadow: 0 2px 0 #c2410c;
}

.operation-option.multiply {
    background-color: #ea580c;
    color: white;
    border-color: #c2410c;
    box-shadow: 0 2px 0 #c2410c;
}

.operation-option:not(:disabled):hover {
    transform: translateY(-2px);
}

.operation-option:disabled {
    opacity: 0.5;
    cursor: default;
}

.result {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 60px;
    flex: 1;
    min-width: 0;
}

.result-display {
    width: 100%;
    max-width: 40px;
    flex: 1;
    min-width: 0;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.result-value {
    width: 100%;
    min-width: 0;
    height: 2.5rem;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.result-value.solved {
    
}

.success-message {
    position: absolute;
    z-index: 1;
    left: 50%;
    bottom: 1rem;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 500px;
    padding: 0 1rem;
}

.success-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: #16a34a;
    margin-bottom: 1rem;
    letter-spacing: 0.02em;
}

.total-stats {
    background-color: #f0fdf4;
    padding: 1rem;
    border-radius: 0.75rem;
    border: 2px solid #dcfce7;
    text-align: center;
}

.total-label {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    letter-spacing: 0.02em;
}

.total-number {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.difficulty-stats {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.difficulty-stat {
    display: flex;
    align-items: center;
}

.difficulty-name {
    flex: 1;
    padding: 0.75rem;
    font-weight: 700;
    color: white;
    border: 2px solid;
    border-radius: 0.5rem 0 0 0.5rem;
    letter-spacing: 0.02em;
}

.difficulty-name.easy {
    background-color: #22c55e;
    border-color: #166534;
}

.difficulty-name.medium {
    background-color: #16a34a;
    border-color: #166534;
}

.difficulty-name.hard {
    background-color: #f97316;
    border-color: #c2410c;
}

.difficulty-name.expert {
    background-color: #ea580c;
    border-color: #c2410c;
}

.difficulty-count {
    width: 5rem;
    background-color: white;
    padding: 0.45rem;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 800;
    border: 2px solid #dcfce7;
    border-left: none;
    border-radius: 0 0.5rem 0.5rem 0;
    letter-spacing: -0.02em;
}

.no-stats {
    background-color: #f0fdf4;
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 2px solid #dcfce7;
    text-align: center;
}

.no-stats p {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: 0.02em;
}

.placeholder {
    width: 2rem;
}

.popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.popup-content {
    background-color: white;
    padding: 1rem;
    border-radius: 1rem;
    text-align: center;
    max-width: 90%;
    width: 400px;
    box-shadow: 0 20px 60px -15px rgba(0, 0, 0, 0.2);
    position: relative;
}

.popup-content .button.icon {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 2rem;
    height: 2rem;
    font-size: 2.5rem;
    line-height: 1;
    padding: 0;
    background-color: transparent;
    color: #4b5563;
    border: none;
    box-shadow: none;
}

.popup-content .button.icon:hover {
    color: #16a34a;
    background-color: transparent;
    transform: none;
    box-shadow: none;
}

.popup h2 {
    color: #16a34a;
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.popup p {
    color: #4b5563;
    margin-bottom: 1.5rem;
    font-size: 1.125rem;
    font-weight: 500;
}

.hint-text {
    font-size: 1rem;
    font-weight: 700;
    margin: 1rem 0;
    padding: 1rem;
    background-color: #f0fdf4;
    border-radius: 0.5rem;
    border: 2px solid #dcfce7;
}

.hint-operation {
    display: inline-block;
    color: #16a34a;
    font-size: 1.25rem;
    font-weight: 800;
    padding: 0.25rem 0.75rem;
    background-color: white;
    border-radius: 0.5rem;
    border: 2px solid #16a34a;
    margin: 0 0.25rem;
    min-width: 2rem;
    text-align: center;
}

.popup .button {
    margin: 0.5rem;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-overlay.is-loading {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f0fdf4;
    border-top: 5px solid #16a34a;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

body.is-loading {
    overflow: hidden;
}