:root {
    --primary-color: #2e7d32; /* 草の緑 */
    --primary-light: #60ad5e;
    --primary-dark: #005005;
    --bg-gradient-top: #e8f5e9;
    --bg-gradient-bottom: #c8e6c9;
    --text-color: #2b3a2f;
    --text-light: #5f7464;
    --white: #ffffff;
    --border-color: rgba(46, 125, 50, 0.2);
    --shadow: 0 8px 32px 0 rgba(0, 50, 0, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.5);
    
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --font-main: 'M PLUS Rounded 1c', sans-serif;
    --font-num: 'Nunito', sans-serif;
}

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

body {
    font-family: var(--font-main);
    color: var(--text-color);
    background: linear-gradient(135deg, var(--bg-gradient-top), var(--bg-gradient-bottom)) no-repeat;
    background-attachment: fixed;
    min-height: 100vh;
}

/* Typography */
h1, h2, h3 {
    font-weight: 800;
}

/* Glassmorphism Classes */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
}

/* Header Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--white);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo h1 {
    font-size: 1.5rem;
    color: var(--primary-dark);
}

.nav-links {
    display: flex;
    gap: 1rem;
}

.nav-btn {
    background: transparent;
    border: none;
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-light);
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.nav-btn:hover {
    background: rgba(46, 125, 50, 0.1);
    color: var(--primary-color);
}

.nav-btn.active {
    background: var(--primary-color);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
}

/* Main Container */
.container {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.view-section {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.view-section.active {
    display: block;
}

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

/* Cards */
.card {
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.card h2 {
    font-size: 1.2rem;
    color: var(--primary-dark);
    margin-bottom: 1rem;
    border-bottom: 2px dashed var(--border-color);
    padding-bottom: 0.5rem;
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.input-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--primary-color);
}

input[type="text"], input[type="date"], input[type="number"], select {
    width: 100%;
    padding: 0.7rem;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    background: rgba(0, 0, 0, 0.03);
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-color);
    transition: all 0.2s ease;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary-light);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(96, 173, 94, 0.2);
}

input[type="number"] {
    font-family: var(--font-num);
    text-align: center;
    font-weight: 800;
}

/* Scoreboard */
.scoreboard-wrapper, .table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 2px;
}

th, td {
    text-align: center;
    padding: 0.5rem;
    border-radius: 4px;
}

th {
    background: var(--primary-color);
    color: var(--white);
    font-family: var(--font-num);
    font-size: 0.9rem;
}

.scoreboard td {
    background: var(--white);
}

.scoreboard input.score-input {
    width: 3rem;
    height: 3rem;
    padding: 0;
    font-size: 1.2rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.total-col {
    background: var(--primary-light);
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--white);
    width: 4rem;
}

.total-score {
    background: var(--primary-dark) !important;
}

.team-name-input {
    min-width: 120px;
    font-weight: 700;
}

/* Batting Table */
.batting-table th {
    background: var(--primary-dark);
}

.batting-table td {
    background: var(--white);
    vertical-align: middle;
}

.batting-table select.result-select {
    font-weight: 700;
    cursor: pointer;
}

.batting-table select.result-select.hr-selected {
    background-color: #ffd54f; /* Gold for HR */
    color: #b71c1c;
    border-color: #ffca28;
    animation: bounce 0.5s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Buttons */
.btn {
    border: none;
    padding: 1rem 2rem;
    font-family: var(--font-main);
    font-weight: 800;
    font-size: 1.1rem;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white);
    box-shadow: 0 6px 15px rgba(46, 125, 50, 0.4);
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 20px rgba(46, 125, 50, 0.5);
}

.btn-primary:active {
    transform: translateY(1px);
    box-shadow: 0 3px 10px rgba(46, 125, 50, 0.4);
}

.float-action {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
}

/* History */
.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.history-item {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    border-top: 5px solid var(--primary-color);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    transition: transform 0.2s ease;
}

.history-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}

.history-date {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.history-title {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 1rem;
}

.history-score {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f1f8f1;
    padding: 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-num);
    font-size: 1.5rem;
    font-weight: 800;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
}

.empty-state p {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

/* Flash animation for scores */
@keyframes flashGreen {
    0% { background-color: var(--primary-light); color: white; }
    100% { background-color: var(--white); color: inherit; }
}

.flash-eff {
    animation: flashGreen 0.8s ease-out;
}

/* Sync Panel */
.sync-panel {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.status-indicator {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    background-color: #e0e0e0;
    color: #555;
    font-weight: bold;
    font-size: 0.8rem;
}

.status-indicator.online-host {
    background-color: #e8f5e9;
    color: var(--primary-dark);
}

.status-indicator.online-guest {
    background-color: #e3f2fd;
    color: #1565c0;
}

.btn-small {
    background: var(--text-light);
    color: white;
    border: none;
    padding: 0.3rem 0.8rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    transition: background 0.2s;
}

.btn-small:hover {
    background: var(--text-color);
}

.input-small {
    padding: 0.3rem 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    width: 120px;
    font-family: inherit;
}

.join-container {
    display: flex;
    gap: 0.3rem;
}

.hidden {
    display: none !important;
}

.room-info {
    font-weight: bold;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    background: #e8f5e9;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

/* Responsive */
@media (max-width: 600px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .sync-panel {
        flex-direction: column;
        align-items: stretch;
    }

    .join-container {
        flex-direction: column;
    }

    .scoreboard input.score-input {
        width: 2rem;
        height: 2.5rem;
        font-size: 1rem;
    }
}
