@import url('https://fonts.googleapis.com/css2?family=IM+Fell+English+SC&family=Poppins:wght@400;500;700&display=swap');

:root {
    --primary-color: #c0392b; /* A darker, more rustic red */
    --secondary-color: #f39c12; /* A richer gold */
    --accent-color: #2980b9; /* A deeper blue */
    --background-color: #1e1a14; /* Dark wood color */
    --paper-bg: #f5eeda; /* Aged paper */
    --text-color: #3d2c1c; /* Dark brown text */
    --border-radius: 8px;
    --header-font: 'IM Fell English SC', serif;
    --body-font: 'Poppins', sans-serif;
}

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

body {
    font-family: var(--body-font);
    background-color: var(--background-color);
    background-image: url('https://www.transparenttextures.com/patterns/wood-pattern.png');
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

h1 {
    font-family: var(--header-font);
    font-size: 3.5rem;
    color: var(--paper-bg);
    text-shadow: 
        2px 2px 0px #000,
        -2px -2px 0px #000,
        2px -2px 0px #000,
        -2px 2px 0px #000,
        4px 4px 5px rgba(0,0,0,0.5);
    font-weight: normal;
    letter-spacing: 2px;
}

.logo-container {
    display: none; /* Logo is now directly in header */
}

.logo {
    max-width: 200px;
    height: auto;
    margin-bottom: 10px;
}

.tabs {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    gap: 15px;
    border: none;
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.tab-btn {
    padding: 12px 30px;
    background: #d3a67c;
    border: 2px solid #5a3e2b;
    border-radius: 5px;
    font-family: var(--header-font);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    color: #5a3e2b;
    box-shadow: 0 4px 0 #5a3e2b, 0 5px 5px rgba(0,0,0,0.3);
    text-transform: uppercase;
}

.tab-btn:hover {
    background-color: #e4b995;
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #5a3e2b, 0 7px 5px rgba(0,0,0,0.3);
}

.tab-btn.active {
    background-color: var(--secondary-color);
    color: white;
    transform: translateY(2px);
    box-shadow: 0 2px 0 #8c5d10, 0 3px 3px rgba(0,0,0,0.3);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.input-section,
.result-section {
    background-color: var(--paper-bg);
    border-radius: var(--border-radius);
    padding: 30px 40px;
    margin-bottom: 30px;
    border: 10px solid transparent;
    border-image: url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cstyle%3E.s%7Bstroke:%235a3e2b;stroke-width:4;stroke-linecap:round;fill:none%7D%3C/style%3E%3Cpath class='s' d='M2,2 L2,98 L98,98 L98,2 Z'/%3E%3Cpath class='s' d='M2,50 Q25,25 50,50 T98,50'/%3E%3Cpath class='s' d='M50,2 Q25,25 50,50 T50,98'/%3E%3C/svg%3E") 15 round;
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
    position: relative;
}

.input-section::before,
.result-section::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 4px;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0));
    pointer-events: none;
}

h2 {
    font-family: var(--header-font);
    font-size: 2.5rem;
    margin-bottom: 25px;
    color: var(--primary-color);
    text-align: center;
    letter-spacing: 1px;
}

h3 {
    font-family: var(--header-font);
    font-size: 1.8rem;
    margin: 25px 0 15px 0;
    color: var(--primary-color);
    border-bottom: 2px solid rgba(61, 44, 28, 0.2);
    padding-bottom: 5px;
}

.prompt-helpers {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    justify-content: flex-end;
}

.btn-secondary {
    background: linear-gradient(to bottom, #5dade2, #3498db);
    color: white;
    border: 2px solid #1a5276;
    padding: 8px 18px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: var(--body-font);
    transition: all 0.2s;
    box-shadow: 0 3px 0 #1a5276;
    font-weight: 500;
}

.btn-secondary:hover {
    background: linear-gradient(to bottom, #85c1e9, #5dade2);
    transform: translateY(-1px);
    box-shadow: 0 4px 0 #1a5276;
}

.btn-secondary:active {
    transform: translateY(1px);
    box-shadow: 0 2px 0 #1a5276;
}

.btn-secondary:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: translateY(0);
    box-shadow: 0 3px 0 #7f8c8d;
    border-color: #7f8c8d;
    color: #e0e0e0;
}

.button-spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.6s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

textarea {
    width: 100%;
    min-height: 150px;
    padding: 15px;
    border: 1px solid #d3c4a8;
    border-radius: var(--border-radius);
    font-family: var(--body-font);
    resize: vertical;
    margin-bottom: 20px;
    font-size: 1rem;
    background-color: #fff;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.08);
}

textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.3), inset 0 2px 4px rgba(0,0,0,0.08);
}

.btn {
    background: linear-gradient(to bottom, #e74c3c, #c0392b);
    color: white;
    border: 2px solid #5a3e2b;
    padding: 14px 30px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: var(--header-font);
    transition: all 0.2s ease;
    box-shadow: 0 5px 0 #88291f, 0 6px 6px rgba(0,0,0,0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: block;
    margin: 0 auto;
}

.btn:hover {
    background: linear-gradient(to bottom, #ff6b5a, #d44a3a);
    transform: translateY(-2px);
    box-shadow: 0 7px 0 #88291f, 0 8px 8px rgba(0,0,0,0.3);
}

.btn:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 #88291f, 0 3px 3px rgba(0,0,0,0.3);
}

.btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: translateY(0);
    box-shadow: 0 5px 0 #7f8c8d;
}

.devil-fruit-selection {
    margin: 20px 0;
    border-top: 1px solid #eee;
    padding-top: 20px;
}

.selection-options {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.selection-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 10px;
    border-radius: 5px;
    transition: background-color 0.2s;
}

.selection-options label:hover {
    background-color: rgba(61, 44, 28, 0.05);
}

input[type="radio"] {
  appearance: none;
  width: 1.5em;
  height: 1.5em;
  border: 2px solid var(--text-color);
  border-radius: 50%;
  transition: all 0.2s;
  cursor: pointer;
  position: relative;
}

input[type="radio"]:checked {
  background-color: var(--secondary-color);
  border-color: var(--text-color);
}
input[type="radio"]:checked::after {
    content: 'X';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    color: var(--text-color);
    font-size: 1em;
}

.hidden {
    display: none;
}

.result-section {
    background-color: var(--paper-bg);
    border-radius: var(--border-radius);
    padding: 30px 40px;
    margin-bottom: 30px;
    border: 10px solid transparent;
    border-image: url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cstyle%3E.s%7Bstroke:%235a3e2b;stroke-width:4;stroke-linecap:round;fill:none%7D%3C/style%3E%3Cpath class='s' d='M2,2 L2,98 L98,98 L98,2 Z'/%3E%3Cpath class='s' d='M2,50 Q25,25 50,50 T98,50'/%3E%3Cpath class='s' d='M50,2 Q25,25 50,50 T50,98'/%3E%3C/svg%3E") 15 round;
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
    position: relative;
    display: none;
}

.result-header {
    margin-bottom: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.star-rating {
    font-size: 2rem;
    color: #f39c12;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.fruit-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.fruit-header-flex h4 {
    margin: 0;
}

.fruit-header-flex .star-rating {
    font-size: 1.5rem;
}

.result-content {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    margin-bottom: 30px;
}

.result-image {
    flex: 1;
    min-width: 280px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    background: rgba(0,0,0,0.05);
    border-radius: var(--border-radius);
}

.result-image img {
    max-width: 100%;
    border-radius: var(--border-radius);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    border: 5px solid #fff;
    background: #eee;
}

.result-info {
    flex: 2;
    min-width: 300px;
}

#attacks-section {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 2px dashed rgba(61, 44, 28, 0.3);
}

#character-attacks {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.attack-card {
    background-color: rgba(255,255,255,0.6);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid #d3c4a8;
    border-left: 5px solid var(--accent-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.attack-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.attack-card h4 {
    color: var(--accent-color);
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(61, 44, 28, 0.2);
    padding-bottom: 8px;
    font-size: 1.2rem;
    font-family: var(--header-font);
}

.loading-spinner {
    display: none;
    width: 50px;
    height: 50px;
    margin: 20px auto;
    border: 5px solid rgba(61, 44, 28, 0.2);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#battle-container {
    background-color: var(--paper-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    border: 10px solid transparent;
    border-image: url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cstyle%3E.s%7Bstroke:%235a3e2b;stroke-width:4;stroke-linecap:round;fill:none%7D%3C/style%3E%3Cpath class='s' d='M2,2 L2,98 L98,98 L98,2 Z'/%3E%3Cpath class='s' d='M2,50 Q25,25 50,50 T98,50'/%3E%3Cpath class='s' d='M50,2 Q25,25 50,50 T50,98'/%3E%3C/svg%3E") 15 round;
}

#battle-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    gap: 20px;
    padding: 10px;
}

#player-stats, #enemy-stats {
    width: 50%;
    padding: 10px;
    background: rgba(0,0,0,0.05);
    border-radius: 5px;
}

#player-stats h3, #enemy-stats h3 {
    margin: 0 0 10px;
    padding: 0;
    font-size: 1.2rem;
    color: var(--text-color);
    border: none;
    text-align: center;
}

.health-bar {
    height: 25px;
    width: 100%;
    background-color: rgba(0,0,0,0.2);
    border-radius: 50px;
    overflow: hidden;
    border: 2px solid var(--text-color);
    padding: 2px;
}

.health-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(to right, #28b463, #58d68d);
    border-radius: 50px;
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

.health-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, rgba(255,255,255,0.4), rgba(255,255,255,0.1) 50%, transparent);
}

#enemy-health {
    background: linear-gradient(to right, #e74c3c, #f1948a);
}

#battle-arena-game {
    width: 100%;
    height: 400px;
    background-color: #f0f0f0;
    position: relative;
    overflow: hidden;
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    border: 3px solid var(--text-color);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

#battle-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-shadow: 2px 2px 4px #000;
}

#battle-loader .loading-spinner {
    display: block;
    margin: 20px auto;
    width: 60px;
    height: 60px;
    border-width: 6px;
    border-left-color: var(--secondary-color);
}

#battle-canvas {
    width: 100%;
    height: 100%;
}

#battle-controls {
    margin-top: 15px;
    background: transparent;
    padding: 0;
    border-radius: var(--border-radius);
}

#abilities-container {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.ability-button {
    background: linear-gradient(to bottom, #3498db, #2980b9);
    color: white;
    border: 2px solid #1a5276;
    padding: 10px 18px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-family: var(--body-font);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 0 #1a5276, 0 5px 5px rgba(0,0,0,0.2);
    min-width: 150px;
}

.ability-button:hover {
    background: linear-gradient(to bottom, #5dade2, #3498db);
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #1a5276, 0 7px 5px rgba(0,0,0,0.2);
}

.ability-button:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #1a5276, 0 3px 3px rgba(0,0,0,0.2);
}

.ability-key {
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255,255,255,0.5);
    padding: 3px 8px;
    border-radius: 5px;
    font-weight: 700;
}

#battle-message {
    background-color: rgba(61, 44, 28, 0.8);
    color: var(--paper-bg);
    padding: 12px;
    border-radius: var(--border-radius);
    text-align: center;
    font-weight: 500;
    transition: all 0.3s;
    border: 2px solid var(--text-color);
}

.character-sprite {
    position: absolute;
    width: 80px;
    height: 80px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: all 0.1s ease;
}

.attack-animation {
    position: absolute;
    pointer-events: none;
    z-index: 10;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}

@media screen and (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .result-content {
        flex-direction: column;
    }
    
    .tabs {
        flex-wrap: wrap;
        gap: 10px;
    }

    .tab-btn {
        padding: 10px 20px;
        font-size: 1rem;
    }
    
    h1 {
        font-size: 2.5rem;
    }

    h2 {
        font-size: 2rem;
    }

    .input-section, .result-section {
        padding: 20px;
        border-width: 8px;
    }
    
    .result-image, .result-info {
        min-width: 100%;
    }

    #battle-stats {
        flex-direction: column;
        gap: 10px;
    }

    #player-stats, #enemy-stats {
        width: 100%;
    }
}