:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #ec4899;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --dark-bg: #0f172a;
    --dark-surface: #1e293b;
    --dark-surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-success: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

/* Global Screenshot/Interaction Enable */
/* Global Screenshot/Interaction Enable */
* {
    /* Prevent accidental selection on mobile */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none !important;
    /* iOS Safari */
    -webkit-tap-highlight-color: transparent;
}

/* Specific fix for links to prevent long-press menu */
a,
button,
.clickable {
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
}

/* Allow text selection in inputs and specifically allowed text areas */
input,
textarea,
[contenteditable="true"],
.selectable-text {
    user-select: text !important;
    -webkit-user-select: text !important;
}

img {
    pointer-events: auto !important;
}

img {
    pointer-events: auto !important;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--dark-bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Prevent horizontal scroll wobble */
html,
body {
    overflow-x: hidden;
    width: 100%;
}

/* ヘッダー */
.header {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.75rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* ハンバーガーメニュー（右上） */
.menu-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.03);
}

.menu-btn .bar {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    margin: 4px 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.menu-btn.open .bar:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.menu-btn.open .bar:nth-child(2) {
    opacity: 0;
}

.menu-btn.open .bar:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.menu-dropdown {
    position: absolute;
    right: 2rem;
    top: 70px;
    background: var(--dark-surface);
    border: 1px solid var(--border-color);
    padding: 0.5rem 0;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    display: none;
    z-index: 2000;
}

.menu-dropdown.show {
    display: block;
    animation: dropdownIn 160ms ease;
}

.menu-dropdown.hide {
    animation: dropdownOut 120ms ease forwards;
}

.menu-item {
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 600;
}

.menu-item:hover {
    background: var(--dark-surface-light);
}

@keyframes dropdownIn {
    from {
        transform: translateY(-6px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes dropdownOut {
    from {
        transform: translateY(0);
        opacity: 1;
    }

    to {
        transform: translateY(-6px);
        opacity: 0;
    }
}

/* 設定モーダル */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.modal-backdrop.show {
    display: flex;
}

.modal {
    background: var(--dark-surface);
    padding: 1.25rem;
    border-radius: 0.75rem;
    width: 90%;
    max-width: 420px;
    border: 1px solid var(--border-color);
}

.modal h3 {
    margin-bottom: 0.75rem;
}

.toggle-switch {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toggle-switch input {
    width: 2rem;
    height: 1rem;
}

.user-name {
    color: var(--text-secondary);
    font-weight: 500;
}

.gold-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--dark-surface-light);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    color: var(--warning-color);
}

.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9375rem;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--dark-surface-light);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--dark-surface);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

/* メインコンテンツ */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.page-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 1.125rem;
    margin-bottom: 2rem;
}

/* ゲームグリッド */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.game-card {
    background: var(--dark-surface);
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    cursor: pointer;
}

.game-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary-color);
}

.game-thumbnail {
    width: 100%;
    height: 200px;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    position: relative;
    overflow: hidden;
}

.game-thumbnail::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(255, 255, 255, 0.1) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.1) 75%),
        linear-gradient(45deg, rgba(255, 255, 255, 0.1) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.1) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    opacity: 0.3;
}

.game-info {
    padding: 1.5rem;
}

.game-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.game-description {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.game-stats {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-light);
}

/* 認証フォーム */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.1), transparent 50%),
        radial-gradient(circle at bottom left, rgba(236, 72, 153, 0.1), transparent 50%);
}

.auth-card {
    background: var(--dark-surface);
    border-radius: 1rem;
    padding: 3rem;
    max-width: 600px;
    width: 100%;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
}

.auth-title {
    font-size: 2rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 0.5rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--dark-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-submit {
    width: 100%;
    padding: 1rem;
    margin-top: 1rem;
    font-size: 1rem;
}

.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-muted);
}

.auth-switch a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.auth-switch a:hover {
    color: var(--primary-color);
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    text-align: center;
}

.success-message {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--success-color);
    color: var(--success-color);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    text-align: center;
}

/* レスポンシブ */
@media (max-width: 768px) {
    .games-grid {
        grid-template-columns: 1fr;
    }

    .header-content {
        flex-direction: row;
        /* Keep row for single line */
        gap: 0.5rem;
        padding: 0 1rem;
    }

    .logo {
        font-size: 1.1rem;
        /* Make logo significantly smaller */
    }

    /* Target buttons inside header specifically for resizing */
    .header .btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }

    .user-info {
        gap: 0.5rem;
    }

    .auth-card {
        padding: 2rem;
    }
}

/* アニメーション */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

/* ローディング */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

/* Age Verification & Terms */
.terms-group {
    background: var(--dark-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-top: 1rem;
}

.terms-scroll {
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    background: var(--dark-surface);
    padding: 0.75rem;
    border-radius: 0.25rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.terms-scroll h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.terms-scroll h3:first-child {
    margin-top: 0;
}

.form-note {
    font-size: 0.8rem;
    color: var(--danger-color);
    margin-top: 0.25rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type='checkbox'] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary-color);
}

.avatar-preview {
    position: relative;
    /* Ensure relative positioning for layers */
    isolation: isolate;
    /* New Fixed Stacking Context */
    border-radius: 8px;
    /* Square with slight rounding */
}

.avatar-layer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform-origin: center center;
    pointer-events: none;
    width: auto;

    height: auto;
}

/* SNS Specific Styles */
.sns-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.sns-main {
    min-width: 0;
    /* Prevent grid blowout */
}

.sns-sidebar {
    position: sticky;
    top: 80px;
    height: fit-content;
    background: var(--dark-surface);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
}

@media (max-width: 900px) {
    .sns-layout {
        grid-template-columns: 1fr;
    }

    .sns-sidebar {
        position: static;
        margin-bottom: 2rem;
    }
}

/* Post Bubble Style */
.post-bubble-container {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.post-avatar-area {
    flex-shrink: 0;
    width: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.post-avatar-img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--dark-surface-light);
    border: 2px solid var(--primary-color);
    object-fit: cover;
}

.post-avatar-name {
    font-size: 0.7rem;
    text-align: center;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}

.post-bubble {
    position: relative;
    background: var(--dark-surface);
    padding: 1rem;
    border-radius: 1rem;
    border-top-left-radius: 0;
    border: 1px solid var(--border-color);
    flex-grow: 1;
}

.post-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: -10px;
    width: 0;
    height: 0;
    border-top: 10px solid var(--dark-surface);
    border-left: 10px solid transparent;
    z-index: 1;
}

.post-bubble::after {
    content: '';
    position: absolute;
    top: -1px;
    left: -11px;
    width: 0;
    height: 0;
    border-top: 11px solid var(--border-color);
    border-left: 11px solid transparent;
    z-index: 0;
}

/* Rich Text Styles */
.text-big {
    font-size: 1.25em;
    font-weight: bold;
}

.text-small {
    font-size: 0.8em;
    opacity: 0.8;
}

/* Animations */
@keyframes float {

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

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

.anim-float {
    display: inline-block;
    animation: float 2s ease-in-out infinite;
}

@keyframes pulse {

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

    50% {
        transform: scale(1.05);
    }
}

.anim-pulse {
    display: inline-block;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-2px);
    }

    75% {
        transform: translateX(2px);
    }
}

.anim-shake {
    display: inline-block;
    animation: shake 0.5s linear infinite;
}

@keyframes rainbow {
    0% {
        color: #fe4a49;
    }

    20% {
        color: #2ab7ca;
    }

    40% {
        color: #fed766;
    }

    60% {
        color: #e6e6ea;
    }

    80% {
        color: #f4f4f8;
    }

    100% {
        color: #fe4a49;
    }
}

.anim-rainbow {
    animation: rainbow 2s linear infinite;
}

/* Decoration Toolbar */
.decoration-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.deco-btn {
    background: var(--dark-surface-light);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.deco-btn:hover:not(:disabled) {
    background: var(--primary-light);
    color: white;
}

.deco-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.preview-area {
    background: var(--dark-bg);
    border: 1px dashed var(--border-color);
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-top: 0.5rem;
    min-height: 3rem;
    font-size: 0.95rem;
}

/* Shop Items */
.shop-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.shop-item:last-child {
    border-bottom: none;
}

.shop-item-info h4 {
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
}

/* SNS Link & Hashtag Visibility */
.post-bubble a {
    color: var(--primary-light);
    text-decoration: none;
    word-break: break-all;
}

.post-bubble a:visited {
    color: var(--primary-light);
    /* Prevent purple visited links */
}

.post-bubble a:hover {
    text-decoration: underline;
    color: var(--primary-color);
}

.hashtag {
    color: #38bdf8 !important;
    /* Bright Sky Blue */
    font-weight: bold;
    background: rgba(56, 189, 248, 0.1);
    padding: 0 4px;
    border-radius: 4px;
    text-decoration: none;
}

.hashtag:hover {
    background: rgba(56, 189, 248, 0.2);
    text-decoration: none;
}

.shop-item-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.shop-cost {
    font-weight: bold;
    color: var(--warning-color);
    font-size: 0.9rem;
}

/* SNS Post Actions Alignment */
.post-actions {
    display: flex;
    align-items: center;
}