@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@700&family=Crimson+Text:ital@0;1&display=swap');

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

body {
    background:
        radial-gradient(ellipse at top, rgba(32, 83, 117, 0.4) 0%, transparent 50%),
        radial-gradient(ellipse at bottom, rgba(184, 134, 87, 0.3) 0%, transparent 50%),
        linear-gradient(135deg, #1a2332 0%, #2a3f5f 25%, #1e4d5c 50%, #2a3f5f 75%, #1a2332 100%);
    padding: 40px 20px;
    font-family: 'Crimson Text', serif;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    animation: twinkle 3s infinite;
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 0.3;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0) 0%, rgba(184, 134, 87, 0.08) 50%, rgba(255, 255, 255, 0) 100%),
        url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><text x="10" y="50" font-size="40" opacity="0.03">✦</text><text x="60" y="80" font-size="30" opacity="0.03">✨</text></svg>'),
        linear-gradient(to bottom, #e8dcc8 0%, #f5ead5 50%, #e8dcc8 100%);
    border: 8px solid #8b6635;
    border-radius: 20px;
    padding: 40px;
    box-shadow:
        0 0 80px rgba(184, 134, 87, 0.6),
        0 0 120px rgba(32, 83, 117, 0.4),
        inset 0 0 60px rgba(184, 134, 87, 0.15),
        inset 0 2px 4px rgba(255, 255, 255, 0.5);
    position: relative;
    z-index: 2;
}

.corner {
    position: absolute;
    width: 80px;
    height: 80px;
    border: 3px solid #8b6635;
}

.corner-tl {
    top: 15px;
    left: 15px;
    border-right: none;
    border-bottom: none;
}

.corner-tr {
    top: 15px;
    right: 15px;
    border-left: none;
    border-bottom: none;
}

.corner-bl {
    bottom: 15px;
    left: 15px;
    border-right: none;
    border-top: none;
}

.corner-br {
    bottom: 15px;
    right: 15px;
    border-left: none;
    border-top: none;
}

h1 {
    font-family: 'Cinzel', serif;
    font-size: 3.2em;
    text-align: center;
    background: linear-gradient(135deg, #1e4d5c 0%, #2a5f70 50%, #1e4d5c 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(184, 134, 87, 0.5);
    filter: drop-shadow(3px 3px 6px rgba(184, 134, 87, 0.4));
    margin-bottom: 10px;
    letter-spacing: 3px;
    position: relative;
}

h1::before,
h1::after {
    content: "✦";
    position: absolute;
    color: #b88657;
    font-size: 0.4em;
    top: 50%;
    transform: translateY(-50%);
    animation: sparkle 2s infinite;
}

h1::before {
    left: -40px;
}

h1::after {
    right: -40px;
    animation-delay: 1s;
}

@keyframes sparkle {

    0%,
    100% {
        opacity: 0.4;
        transform: translateY(-50%) scale(1);
    }

    50% {
        opacity: 1;
        transform: translateY(-50%) scale(1.3);
    }
}

.subtitle {
    text-align: center;
    font-style: italic;
    color: #8b6635;
    margin-bottom: 30px;
    font-size: 1.2em;
}

.wand-divider {
    width: 200px;
    height: 3px;
    background: linear-gradient(90deg, transparent, #8b6635, transparent);
    margin: 20px auto;
    position: relative;
}

.wand-divider::before {
    content: "✦";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: #8b6635;
    font-size: 20px;
    background: #e8dcc8;
    padding: 0 10px;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 30px;
    border: 3px solid #8b6635;
    border-radius: 10px;
    overflow: hidden;
}

th {
    background: linear-gradient(135deg, #1e4d5c 0%, #2a5f70 100%);
    color: #f5ead5;
    padding: 15px;
    text-align: center;
    font-family: 'Cinzel', serif;
    font-size: 1.1em;
    letter-spacing: 1px;
    border-right: 3px solid #8b6635;
}

th:last-child {
    border-right: none;
}

td {
    padding: 15px;
    border-bottom: 2px solid #e6d5b8;
    border-right: 3px solid #e6d5b8;
    background: rgba(255, 255, 255, 0.5);
}

td:last-child {
    border-right: none;
}

tr:last-child td {
    border-bottom: none;
}

tr:nth-child(even) td {
    background: rgba(244, 228, 193, 0.3);
}

.name-cell {
    width: 30%;
    font-weight: bold;
    color: #1e4d5c;
    font-size: 1.3em;
    text-align: center;
}

.achievement-cell {
    width: 70%;
    position: relative;
    cursor: default;
}

.quill-btn {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 24px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 10;
    display: none;
}

.quill-btn.active {
    display: block;
}

.achievement-cell:hover .quill-btn.active {
    opacity: 1;
}

.quill-btn:hover {
    transform: translateY(-50%) scale(1.2);
}

.quill-btn.drawing {
    animation: drawAndFade 1s ease-out;
    animation-fill-mode: forwards;
}

@keyframes drawAndFade {
    0% {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }

    100% {
        opacity: 0;
        transform: translateY(-50%) translateX(400px);
    }
}

.tally-marks {
    display: inline-flex;
    gap: 8px;
    margin-left: 50px;
    align-items: center;
    min-height: 30px;
}

.tally-group {
    display: inline-flex;
    position: relative;
    margin-right: 15px;
}

.tally {
    width: 3px;
    height: 30px;
    background: #1e4d5c;
    margin: 0 3px;
    animation: drawTally 0.5s ease-out;
    transform-origin: top;
}

.tally.diagonal {
    position: absolute;
    width: 40px;
    height: 3px;
    left: -5px;
    top: 50%;
    transform: rotate(-25deg);
    animation: drawDiagonal 0.6s ease-out;
}

@keyframes drawTally {
    from {
        transform: scaleY(0);
        opacity: 0;
    }

    to {
        transform: scaleY(1);
        opacity: 1;
    }
}

@keyframes drawDiagonal {
    from {
        transform: rotate(-25deg) scaleX(0);
        opacity: 0;
    }

    to {
        transform: rotate(-25deg) scaleX(1);
        opacity: 1;
    }
}

.icon {
    display: inline-block;
    margin-right: 8px;
    font-size: 1.2em;
}

.magical-element {
    position: fixed;
    opacity: 0.15;
    pointer-events: none;
    animation: float 20s infinite;
    z-index: 1;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    25% {
        transform: translateY(-30px) rotate(5deg);
    }

    50% {
        transform: translateY(-60px) rotate(-5deg);
    }

    75% {
        transform: translateY(-30px) rotate(3deg);
    }
}

.save-btn {
    display: block;
    margin: 30px auto 0;
    padding: 15px 40px;
    background: linear-gradient(135deg, #1e4d5c 0%, #2a5f70 100%);
    color: #f5ead5;
    border: 3px solid #8b6635;
    border-radius: 10px;
    font-family: 'Cinzel', serif;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(139, 102, 53, 0.3);
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 102, 53, 0.5);
}

.save-btn:active {
    transform: translateY(0);
}

.save-status {
    text-align: center;
    margin-top: 15px;
    font-size: 1.1em;
    font-weight: bold;
    min-height: 25px;
}

.save-status.success {
    color: #2a5f70;
}

.save-status.error {
    color: #8b3535;
}