:root {
    --primary: #34495e;       
    --paper-line: #a4b0be;    
    --paper-bg: #fdfbf7;      
    --red-pen: #e74c3c;       
    --shadow: 2px 4px 0px rgba(0,0,0,0.15);
    --current-team-color: #34495e; 
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; -webkit-tap-highlight-color: transparent; }

body { 
    font-family: 'Patrick Hand', cursive; 
    background-color: var(--paper-bg); 
    color: #2c3e50; 
    height: 100dvh; 
    width: 100vw;
    overflow: hidden; 
    font-size: 16px;
}

.paper-background {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-image: linear-gradient(var(--paper-line) 1px, transparent 1px);
    background-size: 100% 1.5rem; 
    opacity: 0.3; z-index: -1;
    margin-top: 1.5rem; 
}
.paper-background::before {
    content: ''; position: absolute; top: 0; left: 30px; height: 100%; width: 2px;
    background: #ff7675; opacity: 0.6;
}

.app-container { 
    width: 100%; height: 100%; 
    max-width: 500px; 
    margin: 0 auto; 
    position: relative; 
}

.screen {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; flex-direction: column; 
    padding: 15px;
    background: transparent; 
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.4s ease;
    opacity: 0; pointer-events: none; transform: translateY(30px);
    z-index: 0;
}

.screen.active { 
    opacity: 1; 
    pointer-events: all; 
    transform: none; 
    z-index: 10; 
}

.fixed-header { flex-shrink: 0; margin-bottom: 10px; text-align: center; }
.fixed-footer { 
    flex-shrink: 0; margin-top: 10px; 
    padding-bottom: env(safe-area-inset-bottom);
}

.scroll-area {
    flex-grow: 1;
    overflow-y: auto;
    width: 100%;
    padding: 5px;
    -webkit-overflow-scrolling: touch; 
}
.flex-center { display: flex; align-items: center; justify-content: center; }
.no-scroll-flex { overflow: hidden; display: flex; flex-direction: column; justify-content: space-evenly; }

h1 { font-family: 'Indie Flower', cursive; font-size: 2.2rem; color: var(--primary); margin-bottom: 5px; text-align: center; line-height: 1.1; }
h2 { font-family: 'Indie Flower', cursive; font-size: 1.8rem; margin-bottom: 15px; border-bottom: 2px solid var(--current-team-color); display: inline-block; padding: 0 10px; }
.subtitle { text-align: center; color: #666; font-size: 1rem; margin-bottom: 10px; }
.doodle-underline { display: block; height: 10px; width: 120px; background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 10" preserveAspectRatio="none"><path d="M0 5 Q 50 10 100 5" stroke="%2334495e" stroke-width="2" fill="none"/></svg>') no-repeat center; background-size: contain; margin: 0 auto 15px auto; }

.input-group { width: 100%; margin-bottom: 15px; }
.input-group label { display: block; font-weight: bold; color: #555; font-size: 1rem; }
input { 
    width: 100%; padding: 8px 0; background: transparent; 
    border: none; border-bottom: 2px dashed #95a5a6; 
    font-family: 'Patrick Hand', cursive; font-size: 1.1rem; color: var(--primary);
    outline: none; text-align: center; border-radius: 0;
}
input:focus { border-bottom: 2px solid var(--primary); }

.notebook-card {
    background: #fff; padding: 15px; width: 100%; border-radius: 5px;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.1); transform: rotate(-1deg);
    margin-bottom: 15px; border: 1px solid #ddd;
}
.player-list-handwritten { width: 100%; max-height: 150px; overflow-y: auto; }
.player-list-handwritten li {
    list-style: none; padding: 5px 0; border-bottom: 1px solid #eee;
    font-family: 'Indie Flower', cursive; font-size: 1.2rem;
}

button {
    font-family: 'Patrick Hand', cursive; font-size: 1.2rem; font-weight: bold;
    border: 2px solid #333; border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
    cursor: pointer; padding: 12px 20px; 
    transition: transform 0.1s, box-shadow 0.1s;
    box-shadow: var(--shadow);
    text-transform: uppercase; letter-spacing: 1px; width: 100%;
    display: block; 
}
button:active { transform: scale(0.96) translateY(2px); box-shadow: none; }

.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-secondary { background: white; color: var(--primary); border-color: var(--primary); }
.btn-danger { background: #e74c3c; color: white; border-color: #c0392b; }
.btn-success { background: #2ecc71; color: white; border-color: #27ae60; }
.row-buttons { display: flex; gap: 10px; } 

.player-input-row { display: flex; gap: 10px; align-items: center; }
.btn-icon { width: 40px; height: 40px; border-radius: 50%; padding: 0; display: flex; justify-content: center; align-items: center; font-size: 1.2rem; flex-shrink: 0; }

.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 1000; display: none; justify-content: center; align-items: center; }
.modal.open { display: flex; }
.sticky-note {
    background: #ffeaa7; width: 90%; max-width: 320px; padding: 20px;
    box-shadow: 5px 5px 15px rgba(0,0,0,0.3); transform: rotate(1deg);
    font-family: 'Indie Flower', cursive;
    max-height: 80vh; overflow-y: auto;
}
.sticky-note h3 { font-size: 1.8rem; margin-bottom: 10px; border-bottom: 1px solid rgba(0,0,0,0.1); }

.players-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(85px, 1fr)); gap: 10px; width: 100%; }
.player-card {
    background: #ffeb3b; color: #333; padding: 5px; aspect-ratio: 1;
    display: flex; justify-content: center; align-items: center; text-align: center;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2); font-family: 'Indie Flower'; font-size: 1rem;
    cursor: pointer; transform: rotate(1deg); word-break: break-word; border-radius: 4px;
}
.player-card:nth-child(even) { transform: rotate(-1deg); background: #ff9ff3; }
.player-card.completed::after { content: '★'; position: absolute; top: 0; right: 2px; color: green; font-size: 1.2rem; }

.teams-display { display: flex; gap: 10px; overflow-x: auto; padding: 10px 5px; width: 100%; }
.team-col { 
    background: white; border: 2px solid #333; border-radius: 8px; 
    min-width: 130px; flex: 1; padding: 8px; 
    box-shadow: 3px 3px 0 #333; 
}

.mini-scoreboard {
    position: absolute; top: 10px; right: 10px;
    background: #fff; padding: 5px 10px;
    border: 1px solid #ccc;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
    transform: rotate(2deg); z-index: 20;
    font-size: 0.8rem; font-family: 'Indie Flower';
    clip-path: polygon(0 0, 100% 0, 100% 95%, 95% 100%, 5% 100%, 0 95%);
}
.mini-score-row { display: flex; justify-content: space-between; gap: 8px; }

.colored-bg-light { background: var(--paper-bg); }
.colored-bg-light::before {
    content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    border: 6px solid var(--current-team-color); box-sizing: border-box; pointer-events: none; opacity: 0.2;
}

.card-area-wrapper {
    width: 100%; height: 200px;
    display: flex; justify-content: center; align-items: center;
    cursor: pointer;
}
.card-container { width: 85%; max-width: 280px; height: 150px; perspective: 1000px; }
.card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.3s; }
.card.flipped { transform: rotateX(180deg); }

.card-front, .card-back {
    position: absolute; width: 100%; height: 100%; backface-visibility: hidden;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    border-radius: 8px; box-shadow: 2px 4px 10px rgba(0,0,0,0.2);
    border: 1px solid #ddd; background: #fff;
    background-image: linear-gradient(transparent 19px, #eef 20px); background-size: 100% 20px;
}
.card-front { border-top: 4px solid #e74c3c; } 
.card-front span { font-size: 1rem; color: #95a5a6; background: rgba(255,255,255,0.9); padding: 5px; }
.finger-icon { font-size: 1.8rem; margin-top: 5px; animation: bounce 1.5s infinite; }
.card-back { transform: rotateX(180deg); border: 3px solid var(--current-team-color); background: #fff; padding: 10px; }
.card-back span { font-family: 'Indie Flower'; font-size: 1.8rem; font-weight: bold; color: var(--current-team-color); text-align: center; line-height: 1.1; word-wrap: break-word; }

.timer-container { margin: 10px 0; display: flex; justify-content: center; }
.water-sphere {
    width: 80px; height: 80px; border-radius: 50%;
    border: 3px solid #333; position: relative; overflow: hidden; background: white;
    box-shadow: 3px 3px 0 rgba(0,0,0,0.1);
    display: flex; justify-content: center; align-items: center;
}
.water { position: absolute; bottom: 0; left: 0; width: 100%; height: 0%; background: var(--current-team-color); opacity: 0.6; transition: height 1s linear; z-index: 1; }
#timer-text { position: relative; z-index: 2; font-size: 1.8rem; font-weight: bold; color: #333; }

.colored-bg { background: var(--current-team-color); transition: background 0.5s; color: white; }
.center-content { text-align: center; }
.colored-bg h3 { color: rgba(255,255,255,0.8); font-size: 1.2rem; }
.colored-bg h1 { color: white; text-shadow: 2px 2px 0 rgba(0,0,0,0.2); font-size: 3rem; margin: 10px 0; }
.big-start-btn {
    width: 120px; height: 120px; border-radius: 50%;
    background: white; color: var(--current-team-color);
    border: 4px dashed var(--current-team-color); margin: 30px auto;
    font-size: 1.3rem; display: flex; justify-content: center; align-items: center;
    box-shadow: 0 0 0 8px rgba(255,255,255,0.2);
    animation: pulse 2s infinite; cursor: pointer;
}

.honors-container { width: 100%; margin-top: 15px; display: flex; flex-direction: column; gap: 10px; }
.honor-card {
    width: 100%; background: white; padding: 10px; border-radius: 6px;
    display: flex; align-items: center; gap: 10px;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
}
.honor-card.best { border: 2px solid #f1c40f; background: #fff9db; }
.honor-card.worst { border: 2px solid #7f8c8d; background: #ecf0f1; }
.honor-icon { font-size: 2rem; }
.honor-info h2 { font-size: 1.2rem; border: none; margin: 0; }
.honor-info h4 { font-size: 0.9rem; margin: 0; color: #666; }
.honor-comment { font-size: 0.8rem; font-style: italic; color: #888; }

.hidden { display: none !important; }