﻿        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI Mono', monospace;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            color: #333;
        }

        .app-container {
            max-width: 400px;
            margin: 0 auto;
            height: 100vh;
            background: #f3e9d2;
            position: relative;
            overflow: hidden;
            display: flex;
            flex-direction: column;
        }

        .header {
            background: url('header.png') no-repeat center;
            background-size: 100% 100%;
            color: white;
            padding: 20px;
            text-align: center;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
            height: 83px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            position: relative;
        }

        .header.header--profile {
            background: url('Profile_header3.png') no-repeat center;
            background-size: 100% 100%;
        }

        .header.header--profile h1 {
            color: #fff;
            font-weight: 700;
            transform: translateY(0.5ch);
        }

        .header h1 {
            font-size: 25px;
            margin-bottom: 5px;
        }

        .header .subtitle {
            font-size: 15px;
            opacity: 0.9;
        }

        .screen {
            display: none;
            padding: 20px;
            flex: 1;
            overflow-y: auto;
            position: relative;
        }

        #profileDetailScreen {
            padding-bottom: 100px;
        }

        .screen.active {
            display: block;
        }

        .profile-list {
            margin-bottom: 20px;
            max-height: 60vh;
            overflow-y: auto;
        }

        .profile-card {
            background: url('Button4.png') no-repeat center;
            background-size: 100% 100%;
            border-radius: 8px;
            padding: 16px 16px 16px calc(16px + 2ch);
            margin-bottom: 12px;
            box-shadow: none;
            border: none;
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
            color: black;
        }

        .profile-name {
            font-size: 19px;
            font-weight: bold;
            color: black;
            margin-bottom: 8px;
        }

        .profile-stats {
            font-size: 13px;
            color: black;
            display: flex;
            gap: 16px;
        }

        .profile-delete-btn {
            position: absolute;
            top: 12px;
            right: 12px;
            background: #e53e3e;
            color: white;
            border: none;
            border-radius: 50%;
            width: 24px;
            height: 24px;
            font-size: 13px;
            cursor: pointer;
            opacity: 0.7;
            transition: all 0.3s ease;
        }

        .btn {
            background: url('Button4.png') no-repeat center;
            background-size: 100% 100%;
            color: white;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-size: 17px;
            font-weight: 500;
            transition: all 0.3s ease;
            width: 100%;
            height: 60px;
            padding: 0 10px;
            margin-bottom: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .btn-secondary {
            background: url('Button2.png') no-repeat center;
            background-size: 100% 100%;
            color: black;
            font-weight: bold;
        }

        .btn-danger {
            background: url('Button2.png') no-repeat center;
            background-size: 100% 100%;
        }

        .btn-wood {
            background: url('Button2.png') no-repeat center;
            background-size: 100% 100%;
            color: black;
        }

        #createNewProfileBtn {
            font-weight: bold;
        }

        #addDiceFunctionBtn,
        #addSimpleDiceBtn,
        #deleteModeBtn {
            color: black;
            font-weight: bold;
        }

        .input-group {
            margin-bottom: 16px;
        }

        .input-group label {
            display: block;
            margin-bottom: 6px;
            font-weight: 500;
            color: #2d3748;
        }

        .input-group input, .input-group select {
            width: 100%;
            padding: 12px;
            border: 2px solid #e2e8f0;
            border-radius: 8px;
            font-size: 17px;
            transition: border-color 0.3s ease;
        }

        .input-group input:focus, .input-group select:focus {
            outline: none;
            border-color: #667eea;
        }

        .dice-function-card, .simple-dice-card {
            border-radius: 8px;
            margin-bottom: 8px;
            border: none;
            position: relative;
            cursor: pointer;
            background: url('Button4.png') no-repeat center;
            background-size: 100% 100%;
            color: black;
        }

        .dice-function-card {
            padding: 8px;
            padding-left: calc(8px + 2ch);
        }

        .simple-dice-card {
            padding: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .dice-function-card .dice-function-name {
            margin-top: 0.5em;
        }

        .simple-dice-card .dice-function-name {
            margin-bottom: 0;
            width: 100%;
            text-align: center;
            margin-top: 0;
        }

        .dice-function-name {
            font-size: 19px;
            font-weight: bold;
            color: black;
            margin-bottom: 4px;
        }

        .dice-function-name.dice-function-name--medium {
            font-size: 17px;
        }

        .dice-function-name.dice-function-name--small {
            font-size: 13px;
        }

        .dice-function-formula {
            font-family: 'Segoe UI Mono', monospace;
            color: black;
            font-size: 13px;
            margin-bottom: 6px;
        }

        .dice-function-formula--attack {
            display: flex;
            flex-wrap: wrap;
            align-items: baseline;
            column-gap: 6px;
            row-gap: 2px;
        }

        .dice-function-formula--attack .dice-formula-part {
            flex: 0 1 auto;
        }

        .dice-function-formula--attack .dice-formula-separator {
            flex: 0 0 auto;
        }

        .dice-function-formula--attack.dice-function-formula--wrapped .dice-formula-separator {
            display: none;
        }

        .dice-function-formula--attack.dice-function-formula--wrapped .dice-formula-part--damage {
            flex-basis: 100%;
            margin-top: 2px;
        }

        .back-btn, .settings-btn {
            position: absolute;
            top: 0;
            background: none;
            border: none;
            width: 83px;
            height: 83px;
            cursor: pointer;
            padding: 0;
            opacity: 0;
            z-index: 1;
        }

        .back-btn {
            left: 0;
        }

        .settings-btn {
            right: 0;
        }

        .settings-overlay {
            position: fixed;
            top: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 100%;
            max-width: 400px;
            height: 100vh;
            background: rgba(0, 0, 0, 0.5);
            z-index: 1000;
            display: none;
            align-items: center;
            justify-content: center;
        }

        .settings-overlay.active {
            display: flex;
        }

        .settings-panel {
            background: #f3e9d2;
            padding: 30px;
            border-radius: 12px;
            box-shadow: 0 8px 32px rgba(0,0,0,0.3);
            width: 90%;
            max-width: 300px;
        }

        .settings-panel .btn {
            font-weight: bold;
        }

        #profileContent {
            display: flex;
            gap: 16px;
        }

        #profileContent.delete-mode .dice-function-card,
        #profileContent.delete-mode .simple-dice-card {
            outline: 2px dashed rgba(197, 48, 48, 0.8);
            outline-offset: -4px;
        }

        #diceFunctions {
            flex: 3;
            overflow-y: auto;
        }

        #simpleDices {
            flex: 1;
            overflow-y: auto;
        }

        #profileContent.dimmed {
            opacity: 0.3;
            pointer-events: none;
        }

        .empty-state {
            text-align: center;
            padding: 40px 20px;
            color: #718096;
        }

        .empty-state .icon {
            font-size: 49px;
            margin-bottom: 16px;
            opacity: 0.5;
        }

        /* Result popup */
        .result-popup {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            display: none;
            align-items: center;
            justify-content: center;
            background: rgba(0, 0, 0, 0.5);
            z-index: 1000;
        }

        .result-popup .popup-content {
            background: url('Button5.png') no-repeat center;
            background-size: 100% 100%;
            padding: 40px 20px 20px;
            text-align: center;
            width: 80%;
            max-width: 300px;
            color: black;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .result-popup .roll-name {
            font-weight: bold;
        }

        .result-popup .roll-result {
            margin-top: 10px;
        }

        .result-popup .btn {
            margin-top: 20px;
            margin-bottom: 0;
        }

        .dice-animation-overlay {
            position: fixed;
            inset: 0;
            display: none;
            align-items: center;
            justify-content: center;
            background: rgba(0, 0, 0, 0.15);
            z-index: 1500;
            pointer-events: none;
        }

        .dice-animation-overlay.active {
            display: flex;
        }

        .dice-animation-container {
            width: 220px;
            height: 220px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .dice-animation-image {
            max-width: 100%;
            max-height: 100%;
            object-fit: contain;
            pointer-events: none;
        }

        @media (min-width: 480px) {
            .dice-animation-container {
                width: 260px;
                height: 260px;
            }
        }
    
